From b4cf71a18de08825006ed7e7c3b8545e736b1839 Mon Sep 17 00:00:00 2001 From: Victor Toso Date: Mon, 27 Apr 2015 19:57:43 +0200 Subject: tests: use temporary database on thetvdb tests https://bugzilla.gnome.org/show_bug.cgi?id=748422 --- tests/thetvdb/test_thetvdb_utils.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/thetvdb/test_thetvdb_utils.c b/tests/thetvdb/test_thetvdb_utils.c index ef9ab7e..9131a74 100644 --- a/tests/thetvdb/test_thetvdb_utils.c +++ b/tests/thetvdb/test_thetvdb_utils.c @@ -20,10 +20,12 @@ * */ +#include #include #include "test_thetvdb_utils.h" GrlSource *source = NULL; +gchar *tmp_dir = NULL; void test_setup_thetvdb (void) @@ -32,6 +34,12 @@ test_setup_thetvdb (void) GrlRegistry *registry; GError *error = NULL; + tmp_dir = g_build_filename (g_get_tmp_dir (), "test-thetvdb-XXXXXX", NULL); + tmp_dir = g_mkdtemp (tmp_dir); + g_assert_nonnull (tmp_dir); + + g_setenv ("XDG_DATA_HOME", tmp_dir, TRUE); + config = grl_config_new (THETVDB_ID, NULL); grl_config_set_api_key (config, "THETVDB_TEST_MOCK_API_KEY"); @@ -58,8 +66,15 @@ test_shutdown_thetvdb (void) { GrlRegistry *registry; GError *error = NULL; + gchar *db_path; registry = grl_registry_get_default (); grl_registry_unload_plugin (registry, THETVDB_ID, &error); g_assert_no_error (error); + + /* Remove grl-thetvdb database to avoid unecessary grow of tmpdir */ + db_path = g_build_filename (tmp_dir, "grilo-plugins", "grl-thetvdb.db", NULL); + g_remove (db_path); + g_free (db_path); + g_clear_pointer (&tmp_dir, g_free); } -- cgit v1.2.1