[epiphany] Run ephy-migration-test in temporary profile dirs



commit c7a44c90a47243a2e627a92d8535cfe491d49342
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Mar 3 11:23:39 2018 -0600

    Run ephy-migration-test in temporary profile dirs
    
    For two reasons:
    
     1) Now it works if there is no default profile dir, e.g. if epiphany is
        not installed and has never been run.
    
     2) Running tests on the default profile dir is just insane.

 src/profile-migrator/ephy-profile-migrator.c |    2 +-
 tests/ephy-migration-test.c                  |   42 +++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 5 deletions(-)
---
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index acb58f1..e01bc99 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -1233,7 +1233,7 @@ ephy_migrator (void)
   EphyProfileMigrator m;
 
   /* If after this point there's no profile dir, there's no point in
-   * running anything because Epiphany has never run in this sytem, so
+   * running anything because Epiphany has never run in this system, so
    * exit here. */
   if (!profile_dir_exists ())
     return TRUE;
diff --git a/tests/ephy-migration-test.c b/tests/ephy-migration-test.c
index c069585..85d4afc 100644
--- a/tests/ephy-migration-test.c
+++ b/tests/ephy-migration-test.c
@@ -25,24 +25,58 @@
 #include "ephy-file-helpers.h"
 #include "ephy-profile-utils.h"
 
+#include <errno.h>
 #include <gtk/gtk.h>
 
+static char *
+create_test_profile_dir (void)
+{
+  char *tmpdir;
+  GError *error = NULL;
+
+  tmpdir = g_dir_make_tmp ("ephy-migration-test-XXXXXX", &error);
+  g_assert_no_error (error);
+
+  return tmpdir;
+}
+
+static void
+delete_test_profile_dir (const char *tmpdir)
+{
+  gboolean ret;
+  GError *error = NULL;
+
+  ret = ephy_file_delete_dir_recursively (tmpdir, &error);
+  g_assert_true (ret);
+  g_assert_no_error (error);
+}
+
 static void
 test_do_migration_simple (void)
 {
   gboolean ret;
+  char *tmpdir;
+
+  tmpdir = create_test_profile_dir ();
+  ret = ephy_profile_utils_do_migration (tmpdir, -1, TRUE);
+  g_assert_true (ret);
 
-  ret = ephy_profile_utils_do_migration (NULL, -1, TRUE);
-  g_assert (ret);
+  delete_test_profile_dir (tmpdir);
+  g_free (tmpdir);
 }
 
 static void
 test_do_migration_invalid (void)
 {
   gboolean ret;
+  char *tmpdir;
+
+  tmpdir = create_test_profile_dir ();
+  ret = ephy_profile_utils_do_migration (tmpdir, EPHY_PROFILE_MIGRATION_VERSION + 1, TRUE);
+  g_assert_false (ret);
 
-  ret = ephy_profile_utils_do_migration (NULL, EPHY_PROFILE_MIGRATION_VERSION + 1, TRUE);
-  g_assert (ret == FALSE);
+  delete_test_profile_dir (tmpdir);
+  g_free (tmpdir);
 }
 
 int


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