[Pkg-mozext-commits] [perspectives-extension] 21/30: Unit tests - Fix setup and teardown for notary parsing tests; refactor tests so they run corretly

David Prévot taffit at alioth.debian.org
Thu Sep 26 22:31:40 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch debian
in repository perspectives-extension.

commit 723d04e3038ffce5fd99b53e1a499f2c408d527c
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date:   Sat Sep 14 23:46:54 2013 -0600

    Unit tests - Fix setup and teardown for notary parsing tests; refactor tests so they run corretly
---
 test/test.html |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/test/test.html b/test/test.html
index 77bb8e9..37a2c98 100644
--- a/test/test.html
+++ b/test/test.html
@@ -315,6 +315,9 @@ function notary_parsing() {
 
   write_string("Starting notary parsing tests.");
 
+  // save preferences so we can restore state afterward
+  orig_extra_notaries = Perspectives.root_prefs.getCharPref(pref_string_extra_notaries);
+  orig_use_default_notaries = Perspectives.root_prefs.getBoolPref(pref_string_use_def_notary);
 
   if (orig_extra_notaries == null || orig_use_default_notaries == null) {
     error("Could not read preferences from Perspectives plugin. Skipping notary parse tests.");
@@ -329,17 +332,20 @@ function notary_parsing() {
   Perspectives.root_prefs.setBoolPref(pref_string_use_def_notary, true);
 
   var notaries = "";
-  var initial_notary_count = 8; // Note: update if we change the default file
+  var count_before = 0;
 
   notaries = Perspectives.getNotaryList();
-  assert(notaries.length == initial_notary_count,
-    "Default notary list gets us " + initial_notary_count + " notaries ");
+  assert(notaries.length > 0,
+    "Default notary list gets us > 0 notaries (we have " + notaries.length + ")");
 
 
   var nonsense_notary = "aaaaaaaa";
+  // clear the extra notaries list to be sure what we're dealing with
+  Perspectives.root_prefs.setCharPref(pref_string_extra_notaries, "");
+  count_before = Perspectives.getNotaryList().length;
   Perspectives.root_prefs.setCharPref(pref_string_extra_notaries, nonsense_notary);
   notaries = Perspectives.getNotaryList();
-  assert(notaries.length == initial_notary_count,
+  assert(notaries.length == count_before,
     "Trying to save a garbled notary string doesn't work.");
 
 
@@ -356,9 +362,11 @@ FHBSCs9X+bvVMgPOiEpxZXfaynOQ3TLGYtVywLRwW5yvlRq4E9z0rtvwR1bn1hVd\
 JaJ2Lw7kRVMCAwEAAQ==\
 -----END PUBLIC KEY-----";
 
+  Perspectives.root_prefs.setCharPref(pref_string_extra_notaries, "");
+  count_before = Perspectives.getNotaryList().length;
   Perspectives.root_prefs.setCharPref(pref_string_extra_notaries, notary_dupe);
   notaries = Perspectives.getNotaryList();
-  assert(notaries.length == initial_notary_count,
+  assert_fixme(notaries.length == count_before,
     "Trying to add a duplicate notary doesn't work.");
   //FIXME - note: this currently fails. We want to write code to prevent dupes.
 
@@ -373,9 +381,11 @@ FHBSCs9X+bvVMgPOiEpxZXfaynOQ3TLGYtVywLRwW5yvlRq4E9z0rtvwR1bn1hVd\n\n\n\n\
 JaJ2Lw7kRVMCAwEAAQ==\n\n\n\n\
 -----END PUBLIC KEY-----\n\n\n\n";
 
+  Perspectives.root_prefs.setCharPref(pref_string_extra_notaries, "");
+  count_before = Perspectives.getNotaryList().length;
   Perspectives.root_prefs.setCharPref(pref_string_extra_notaries, sparse_notary);
   notaries = Perspectives.getNotaryList();
-  assert(notaries.length == (initial_notary_count + 1),
+  assert(notaries.length == (count_before + 1),
     "Trying to add a notary with many blank lines works.");
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/perspectives-extension.git



More information about the Pkg-mozext-commits mailing list