Add a test for the maxage option to test-rawdog.
authorAdam Sampson <ats@offog.org>
Sat, 23 Aug 2014 12:57:34 +0000 (13:57 +0100)
committerAdam Sampson <ats@offog.org>
Sat, 23 Aug 2014 12:57:34 +0000 (13:57 +0100)
NEWS
test-rawdog

diff --git a/NEWS b/NEWS
index f37fffa8bd34dfffb0e58e06252e06d10b7d5047..f2021d1fa1aa8cfb2c3879711d074da0b0227d37 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+- rawdog 2.20
+
+Add a test for the maxage option (suggested by joelmo).
+
 - rawdog 2.19
 
 Make test-rawdog not depend on having a host it can test connection
index e7a813e55ce117d158e6cc68d464f79ab17fe865..0e2ecd184b85577e7d025b070d7378365389699e 100755 (executable)
@@ -443,6 +443,19 @@ make_n () {
        make_range 1 "$@"
 }
 
+# Make time.time() return a fixed value.
+fake_time () {
+       # A test can use this more than once within the same second, so the
+       # .pyc's timestamp might not change. Ensure it gets deleted.
+       rm -f $statedir/plugins/fake_time.*
+       cat >$statedir/plugins/fake_time.py <<EOF
+import time
+def fake_time():
+    return $1
+time.time = fake_time
+EOF
+}
+
 range () {
        seq -f "range-title-%.f-" $1 $2
 }
@@ -902,6 +915,20 @@ runs -uw
 output_n 10
 not_output_range 11 20
 
+begin "maxage 30m"
+fake_time 1408794484.0
+make_n 10 $httpdir/feed.rss
+add "maxage 30m"
+add "feed 0 $httpurl/feed.rss"
+runs -uw
+output_n 10
+# This is 45 minutes later than the time above.
+fake_time 1408797184.0
+make_n 20 $httpdir/feed.rss
+runs -uw
+not_output_range 1 10
+output_range 11 20
+
 begin "keepmin 10"
 make_n 20 $httpdir/feed.rss
 add "keepmin 10"