[folks/folks-0-10] tests: Factor out common database disambiguation in EDS tests



commit 675545d07c550df12bac3cdb0ddd98ae432cf17d
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Jan 22 17:35:52 2015 +0000

    tests: Factor out common database disambiguation in EDS tests
    
    Why not just make all the tests use unique databases?

 tests/eds/anti-linking.vala  |   11 -----------
 tests/eds/link-personas.vala |   11 -----------
 tests/eds/perf.vala          |    9 ---------
 tests/eds/set-avatar.vala    |    9 ---------
 tests/lib/eds/test-case.vala |    5 ++++-
 5 files changed, 4 insertions(+), 41 deletions(-)
---
diff --git a/tests/eds/anti-linking.vala b/tests/eds/anti-linking.vala
index ef7fd0f..d03c373 100644
--- a/tests/eds/anti-linking.vala
+++ b/tests/eds/anti-linking.vala
@@ -29,7 +29,6 @@ public class AntiLinkingTests : EdsTest.TestCase
   private bool _found_before_update;
   private bool _found_after_update;
   private bool _found_after_final_update;
-  private int _test_num = -1;
 
   /* NOTE: each full name should remain unique */
   private const string _full_name_1 = "bernie h. innocenti";
@@ -53,16 +52,6 @@ public class AntiLinkingTests : EdsTest.TestCase
       this._found_after_final_update = false;
     }
 
-  public override void create_backend ()
-    {
-      /* Create a new backend (by name) each set up to guarantee we don't
-       * inherit state from the last test.
-       * FIXME: bgo#690830 */
-      this._test_num++;
-      this.eds_backend = new EdsTest.Backend ();
-      this.eds_backend.set_up (false, @"test$_test_num");
-    }
-
   public override void tear_down ()
     {
       /* necessary to clean out some stale state */
diff --git a/tests/eds/link-personas.vala b/tests/eds/link-personas.vala
index 924ba65..47b2df9 100644
--- a/tests/eds/link-personas.vala
+++ b/tests/eds/link-personas.vala
@@ -47,7 +47,6 @@ public class LinkPersonasTests : EdsTest.TestCase
   private HashSet<Persona> _personas;
   private Gee.HashMap<string, string> _linking_props;
   private LinkingMethod _linking_method;
-  private int _test_num = -1;
 
   public LinkPersonasTests ()
     {
@@ -63,16 +62,6 @@ public class LinkPersonasTests : EdsTest.TestCase
           this.test_linking_via_email_as_im_address);
     }
 
-  public override void create_backend ()
-    {
-      /* Create a new backend (by name) each set up to guarantee we don't
-       * inherit state from the last test.
-       * FIXME: bgo#690830 */
-      this._test_num++;
-      this.eds_backend = new EdsTest.Backend ();
-      this.eds_backend.set_up (false, @"test$_test_num");
-    }
-
   public void test_linking_personas_via_im_addresses ()
     {
       this._linking_method = LinkingMethod.IM_ADDRESSES;
diff --git a/tests/eds/perf.vala b/tests/eds/perf.vala
index 622930c..8125e35 100644
--- a/tests/eds/perf.vala
+++ b/tests/eds/perf.vala
@@ -78,15 +78,6 @@ public class PerfTests : EdsTest.TestCase
       this._add_500 ();
     }
 
-  private uint _test_num = 0;
-
-  public override void create_backend ()
-    {
-      /* Use a unique e-d-s book for each test. */
-      this.eds_backend = new EdsTest.Backend ();
-      ((!) this.eds_backend).set_up (true, "test%u".printf (this._test_num++));
-    }
-
   /* Prepare the individual aggregator and wait for it to quiesce. */
   private async IndividualAggregator _aggregate () throws Error
     {
diff --git a/tests/eds/set-avatar.vala b/tests/eds/set-avatar.vala
index 9afba0e..e317e2f 100644
--- a/tests/eds/set-avatar.vala
+++ b/tests/eds/set-avatar.vala
@@ -39,15 +39,6 @@ public class SetAvatarTests : EdsTest.TestCase
           this.test_set_individual_avatar);
     }
 
-  private uint _test_num = 0;
-
-  public override void create_backend ()
-    {
-      /* Use a unique EDS book for each test. */
-      this.eds_backend = new EdsTest.Backend ();
-      ((!) this.eds_backend).set_up (true, "test%u".printf (this._test_num++));
-    }
-
   void test_set_avatar ()
     {
       Gee.HashMap<string, Value?> c1 = new Gee.HashMap<string, Value?> ();
diff --git a/tests/lib/eds/test-case.vala b/tests/lib/eds/test-case.vala
index 6e6e5ce..ed190ea 100644
--- a/tests/lib/eds/test-case.vala
+++ b/tests/lib/eds/test-case.vala
@@ -164,6 +164,8 @@ public class EdsTest.TestCase : Folks.TestCase
       this.configure_primary_store ();
     }
 
+  private uint _test_num = 0;
+
   /**
    * Virtual method to create and set up the EDS backend.
    * Called from set_up(); may be overridden to not create the backend,
@@ -173,8 +175,9 @@ public class EdsTest.TestCase : Folks.TestCase
    */
   public virtual void create_backend ()
     {
+      /* Use a unique EDS book for each test. */
       this.eds_backend = new EdsTest.Backend ();
-      ((!) this.eds_backend).set_up ();
+      ((!) this.eds_backend).set_up (true, "test%u".printf (this._test_num++));
     }
 
   /**


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