[folks] eds test: create a new address book for each test to avoid inheriting state



commit 0e8f8f23b9502c0582d5fa1a4d815d4da0c5a43f
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Thu Jan 3 22:23:04 2013 -0800

    eds test: create a new address book for each test to avoid inheriting state
    
    This fixes a bug where the second anti-linking test would fail if it ran
    after the first.

 tests/eds/anti-linking.vala  |   18 +++++++++++++-----
 tests/eds/link-personas.vala |    3 ++-
 2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/tests/eds/anti-linking.vala b/tests/eds/anti-linking.vala
index 30bc909..9a68342 100644
--- a/tests/eds/anti-linking.vala
+++ b/tests/eds/anti-linking.vala
@@ -30,6 +30,7 @@ public class AntiLinkingTests : Folks.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";
@@ -50,7 +51,12 @@ public class AntiLinkingTests : Folks.TestCase
       this._found_after_update = false;
       this._found_after_final_update = false;
       this._eds_backend = new EdsTest.Backend ();
-      this._eds_backend.set_up ();
+
+      /* 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.set_up (false, @"test$_test_num");
 
       /* We configure eds as the primary store */
       var config_val = "eds:%s".printf (this._eds_backend.address_book_uid);
@@ -60,6 +66,12 @@ public class AntiLinkingTests : Folks.TestCase
   public override void tear_down ()
     {
       this._eds_backend.tear_down ();
+
+      Environment.unset_variable ("FOLKS_PRIMARY_STORE");
+
+      /* necessary to clean out some stale state */
+      this._eds_backend = null;
+      this._aggregator = null;
     }
 
   /* Confirm that basic anti-linking works for two Personas who have a common
@@ -77,8 +89,6 @@ public class AntiLinkingTests : Folks.TestCase
       this._found_before_update = false;
       this._found_after_update = false;
 
-      this._eds_backend.reset ();
-
       c = new Gee.HashMap<string, Value?> ();
       v = Value (typeof (string));
       v.set_string (_full_name_1);
@@ -206,8 +216,6 @@ public class AntiLinkingTests : Folks.TestCase
       this._found_before_update = false;
       this._found_after_update = false;
 
-      this._eds_backend.reset ();
-
       c = new Gee.HashMap<string, Value?> ();
       v = Value (typeof (string));
       v.set_string (_full_name_1);
diff --git a/tests/eds/link-personas.vala b/tests/eds/link-personas.vala
index bdee12c..09aa0e2 100644
--- a/tests/eds/link-personas.vala
+++ b/tests/eds/link-personas.vala
@@ -69,7 +69,8 @@ public class LinkPersonasTests : Folks.TestCase
       this._eds_backend = new EdsTest.Backend ();
 
       /* Create a new backend (by name) each set up to guarantee we don't
-       * inherit state from the last test */
+       * inherit state from the last test.
+       * FIXME: bgo#690830 */
       this._test_num++;
       this._eds_backend.set_up (false, @"test$_test_num");
 



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