summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorMathias Hasselmann <mathias@openismus.com>2012-10-22 15:28:38 +0200
committerJuan A. Suarez Romero <jasuarez@igalia.com>2012-10-22 16:53:42 +0000
commitddb0065aa12b0df2b4a3db1770d816039438c38b (patch)
tree37f2c17faa13ba4ce735f534227fed07710964f1 /libs
parente3169e267a04258342f677b64b5ccb0072a96b12 (diff)
downloadgrilo-ddb0065aa12b0df2b4a3db1770d816039438c38b.tar.gz
net: Don't fallback to "grl-net-mock-data.ini"
Just print a warning and disable mocking if the specified mock response file cannot be found.
Diffstat (limited to 'libs')
-rw-r--r--libs/net/grl-net-mock.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/libs/net/grl-net-mock.c b/libs/net/grl-net-mock.c
index db4cc70..37450c2 100644
--- a/libs/net/grl-net-mock.c
+++ b/libs/net/grl-net-mock.c
@@ -152,23 +152,19 @@ get_content_mocked (GrlNetWc *self,
void init_mock_requester (GrlNetWc *self)
{
char *config_filename = g_strdup (g_getenv (GRL_NET_MOCKED_VAR));
+ enable_mocking = FALSE;
if (config_filename == NULL) {
- enable_mocking = FALSE;
- return;
+ return;
}
enable_mocking = TRUE;
/* Read configuration file. */
- if (config_filename)
- GRL_DEBUG ("Trying to load mock file \"%s\"", config_filename);
- else
- config_filename = g_strdup ("grl-net-mock-data.ini");
-
GError *error = NULL;
config = g_key_file_new ();
+ GRL_DEBUG ("Loading mock responses from \"%s\"", config_filename);
g_key_file_load_from_file (config, config_filename, G_KEY_FILE_NONE, &error);
int version = 0;
@@ -182,12 +178,15 @@ void init_mock_requester (GrlNetWc *self)
version = g_key_file_get_integer (config, "default", "version", &error);
if (error || version < GRL_MOCK_VERSION) {
- GRL_WARNING ("Unsupported mock version %d.", version);
+ GRL_WARNING ("Unsupported mock version.");
g_clear_error (&error);
+ } else {
+ enable_mocking = TRUE;
}
}
- if (version < GRL_MOCK_VERSION) {
+ if (!enable_mocking) {
+ g_free (config_filename);
g_key_file_unref (config);
config = NULL;
return;
@@ -195,11 +194,7 @@ void init_mock_requester (GrlNetWc *self)
char **parameter_names = g_key_file_get_string_list (config, "default",
"ignored-parameters",
- NULL, &error);
- if (error) {
- parameter_names = NULL;
- g_clear_error (&error);
- }
+ NULL, NULL);
/* Build regular expressions for ignored query parameters. */
if (parameter_names) {