summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Toso <me@victortoso.com>2015-04-27 19:57:43 +0200
committerBastien Nocera <hadess@hadess.net>2015-08-25 18:08:19 +0200
commitb4cf71a18de08825006ed7e7c3b8545e736b1839 (patch)
treecb5ed91bd43880103a0a7326bec6c063d79095a3
parentbd39ef84678f83e876bd412b8a6fdc88cfeab1d0 (diff)
downloadgrilo-plugins-b4cf71a18de08825006ed7e7c3b8545e736b1839.tar.gz
tests: use temporary database on thetvdb tests
https://bugzilla.gnome.org/show_bug.cgi?id=748422
-rw-r--r--tests/thetvdb/test_thetvdb_utils.c15
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);
}