[grilo/mocking] net: Add version field to captured mock config
- From: Mathias Hasselmann <hasselmm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo/mocking] net: Add version field to captured mock config
- Date: Mon, 22 Oct 2012 16:41:12 +0000 (UTC)
commit cacb8d5ec6545c9ebaeaf0d15f3667dbd73b4fae
Author: Mathias Hasselmann <mathias openismus com>
Date: Mon Oct 22 18:40:49 2012 +0200
net: Add version field to captured mock config
libs/net/grl-net-mock-private.h | 1 +
libs/net/grl-net-mock.c | 4 +---
libs/net/grl-net-private.c | 7 ++++++-
3 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/libs/net/grl-net-mock-private.h b/libs/net/grl-net-mock-private.h
index 2a3cea4..ff4d7a4 100644
--- a/libs/net/grl-net-mock-private.h
+++ b/libs/net/grl-net-mock-private.h
@@ -26,6 +26,7 @@
#include "grl-net-wc.h"
#define GRL_NET_MOCKED_VAR "GRL_NET_MOCKED"
+#define GRL_NET_MOCK_VERSION 1
G_GNUC_INTERNAL
gboolean is_mocked (void);
diff --git a/libs/net/grl-net-mock.c b/libs/net/grl-net-mock.c
index 2f92480..f7b489a 100644
--- a/libs/net/grl-net-mock.c
+++ b/libs/net/grl-net-mock.c
@@ -35,8 +35,6 @@
#include "grl-net-mock-private.h"
-#define GRL_MOCK_VERSION 1
-
static GKeyFile *config = NULL;
static GRegex *ignored_parameters = NULL;
static char *base_path = NULL;
@@ -176,7 +174,7 @@ void init_mock_requester (GrlNetWc *self)
/* Check if we managed to load a file */
version = g_key_file_get_integer (config, "default", "version", &error);
- if (error || version < GRL_MOCK_VERSION) {
+ if (error || version < GRL_NET_MOCK_VERSION) {
GRL_WARNING ("Unsupported mock version.");
g_clear_error (&error);
} else {
diff --git a/libs/net/grl-net-private.c b/libs/net/grl-net-private.c
index 257dce5..13b2e72 100644
--- a/libs/net/grl-net-private.c
+++ b/libs/net/grl-net-private.c
@@ -29,6 +29,7 @@
#endif
#include "grl-net-private.h"
+#include "grl-net-mock-private.h"
#include <glib/gstdio.h>
#include <errno.h>
@@ -107,10 +108,11 @@ init_dump_directory ()
return;
}
- if (capture_dir && g_mkdir_with_parents (capture_dir, 0700)) {
+ if (capture_dir && g_mkdir_with_parents (capture_dir, 0700) != 0) {
GRL_WARNING ("Could not create capture directory \"%s\": %s",
capture_dir, g_strerror (errno));
capture_dir = NULL;
+ return;
}
}
@@ -160,6 +162,9 @@ dump_data (SoupURI *uri,
if (!stream) {
GRL_WARNING ("Could not write contents to disk: %s", g_strerror (errno));
} else {
+ if (ftell (stream) == 0)
+ fprintf (stream, "[default]\nversion=%d\n\n", GRL_NET_MOCK_VERSION);
+
fprintf (stream, "[%s]\ndata=%s\n\n", uri_string, request_filename);
fclose (stream);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]