[Pkg-mozext-commits] [perspectives-extension] 11/18: Unit tests - Add tests to compare 'weakly seen' with and without gaps
David Prévot
taffit at alioth.debian.org
Fri Oct 25 18:24:30 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 e57b91114b56ead2d0592837b386b1bb3f4f7f68
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date: Sun Oct 13 23:47:19 2013 -0600
Unit tests - Add tests to compare 'weakly seen' with and without gaps
---
test/test.html | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/test/test.html b/test/test.html
index 42db217..01a379c 100644
--- a/test/test.html
+++ b/test/test.html
@@ -308,6 +308,13 @@ function quorum_basics() {
(end_time_1 - start_time_1 + 1) + ", not " + (cur_time - start_time_1 + 1) +
": got " + gap_quorum_duration1 + ").");
+ // the 'weakly seen' property is relative to the current time,
+ // so allow a check length going back to the end date of the observation.
+ var weak_check_time_limit = Pers_util.SEC2DAY(Pers_util.get_unix_time() - end_time_2);
+ var gap_weakly_seen1 = Pers_client_policy.key_weakly_seen_by_quorum(key,
+ gap_result_list, 1, weak_check_time_limit);
+ assert((gap_weakly_seen1 === false), "key is not 'weakly seen'");
+
assert(end_time_2 > (cur_time - max_stale_sec), "Gap setup: New target key2 ends inside the cutoff limit");
var gap_quorum_duration2 = Pers_client_policy.get_quorum_duration(key2,
gap_result_list, 1, max_stale_sec, cur_time);
@@ -315,6 +322,10 @@ function quorum_basics() {
(end_time_2 - start_time_2 + 1) + ", not " + (cur_time - start_time_2 + 1) +
": got " + gap_quorum_duration2 + ").");
+ var gap_weakly_seen2 = Pers_client_policy.key_weakly_seen_by_quorum(key2,
+ gap_result_list, 1, weak_check_time_limit);
+ assert((gap_weakly_seen2 === false), "key2 is not 'weakly seen'");
+
// if we had the same result set without the gap, the durations should be the same
spacer("Gap and non-gap durations should be the same");
end_time_2 = start_time_1; // all other variables from above are the same.
@@ -347,6 +358,14 @@ function quorum_basics() {
": got " + nongap_quorum_duration1 + ").");
assert((nongap_quorum_duration1 === gap_quorum_duration1), "Duration is the same with and without gaps.");
+ // the 'weakly seen' property is relative to the current time,
+ // so allow a check length going back to the end date of the observation.
+ var weak_check_time_limit = Pers_util.SEC2DAY(Pers_util.get_unix_time() - end_time_2);
+ var nongap_weakly_seen1 = Pers_client_policy.key_weakly_seen_by_quorum(key,
+ non_gap_result_list, 1, weak_check_time_limit);
+ assert((nongap_weakly_seen1 === false), "key is not 'weakly seen'");
+ assert((nongap_weakly_seen1 === gap_weakly_seen1), "'weakly seen' result is the same with and without gaps.");
+
assert(end_time_2 > (cur_time - max_stale_sec), "Nongap setup: New target key2 ends inside the cutoff limit");
var nongap_quorum_duration2 = Pers_client_policy.get_quorum_duration(key2,
non_gap_result_list, 1, max_stale_sec, cur_time);
@@ -355,6 +374,13 @@ function quorum_basics() {
": got " + nongap_quorum_duration2 + ").");
assert((nongap_quorum_duration2 === gap_quorum_duration2), "Duration is the same with and without gaps.");
+ // the 'weakly seen' property is relative to the current time,
+ // so allow a check length going back to the end date of the observation.
+ var nongap_weakly_seen2 = Pers_client_policy.key_weakly_seen_by_quorum(key2,
+ non_gap_result_list, 1, weak_check_time_limit);
+ assert((nongap_weakly_seen2 === false), "key is not 'weakly seen'");
+ assert((nongap_weakly_seen2 === gap_weakly_seen2), "'weakly seen' result is the same with and without gaps.");
+
spacer("Further gap tests");
end_time_2 = orig_end_time_2;
start_time_2 = orig_start_time_2;
--
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