[grilo-plugins] tests: use temporary database on thetvdb tests



commit b4cf71a18de08825006ed7e7c3b8545e736b1839
Author: Victor Toso <me victortoso com>
Date:   Mon Apr 27 19:57:43 2015 +0200

    tests: use temporary database on thetvdb tests
    
    https://bugzilla.gnome.org/show_bug.cgi?id=748422

 tests/thetvdb/test_thetvdb_utils.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
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 <glib/gstdio.h>
 #include <grilo.h>
 #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);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]