Add more tests for the changeconfig option.
authorAdam Sampson <ats@offog.org>
Sun, 26 Jan 2014 19:21:22 +0000 (19:21 +0000)
committerAdam Sampson <ats@offog.org>
Sun, 26 Jan 2014 19:21:22 +0000 (19:21 +0000)
In particular, test with splitstate both on and off, since the
behaviour's different.

NEWS
test-rawdog

diff --git a/NEWS b/NEWS
index c9a2567e7f662f69e98bc313c02dc7beae79514a..1513ab078b4424193e8075d6f1efff9314aaa57c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@
 Make test-rawdog not depend on having a host it can test connection
 timeouts against, and add a -T option if you do have one.
 
+Add some more comprehensive tests for the changeconfig option; in
+particular, test it more thoroughly with splitstate both on and off.
+
 - rawdog 2.18
 
 Be consistent about catching AttributeError when looking for attributes
index 752e43e808ae1c36c6ee0ac88efda316e001e0b1..2e86d7feac6176ccadb4dc7506353a273d7d086d 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # test-rawdog: run some basic tests to make sure rawdog's working.
-# Copyright 2013 Adam Sampson <ats@offog.org>
+# Copyright 2013, 2014 Adam Sampson <ats@offog.org>
 #
 # rawdog is free software; you can redistribute and/or modify it
 # under the terms of that license as published by the Free Software
@@ -1424,13 +1424,16 @@ add "feed 0 $httpurl/301/new.rss"
 rune "You should update its entry" -u
 contains $statedir/config "$httpurl/301/new.rss"
 
-begin "HTTP 301 permanent redirect, changeconfig true"
-make_rss20 $httpdir/new.rss
-add "changeconfig true"
-add "feed 0 $httpurl/301/new.rss"
-rune "has been updated automatically" -u
-contains $statedir/config "$httpurl/new.rss"
-runs -u
+for state in false true; do
+       begin "HTTP 301 permanent redirect, changeconfig true, splitstate $state"
+       make_rss20 $httpdir/new.rss
+       add "changeconfig true"
+       add "splitstate $state"
+       add "feed 0 $httpurl/301/new.rss"
+       rune "has been updated automatically" -u
+       contains $statedir/config "$httpurl/new.rss"
+       runs -u
+done
 
 begin "HTTP 302 to 301"
 # We should only update config if the first redirect is permanent.
@@ -1479,7 +1482,7 @@ for state in false true; do
 done
 
 for state in false true; do
-       begin "HTTP 301, moving items from existing feed, splitstate $state"
+       begin "changeconfig moving items from existing feed, splitstate $state"
        make_range 1 5 $httpdir/old.rss
        add "splitstate $state"
        add "keepmin 20"
@@ -1496,6 +1499,47 @@ for state in false true; do
        output_range 1 10
 done
 
+begin "changeconfig for feed from included file"
+make_rss20 $httpdir/feed.rss
+add "changeconfig true"
+add "include config2"
+echo >$statedir/config2 "feed 0 $httpurl/301/feed.rss"
+rune "has been updated automatically" -u
+# FIXME: this behaviour is probably not what the user wanted.
+# rawdog should probably complain that it's trying to change
+# something but hasn't succeeded.
+not_contains $statedir/config "$httpurl/feed.rss"
+contains $statedir/config2 "$httpurl/301/feed.rss"
+not_contains $statedir/config2 "$httpurl/feed.rss"
+
+begin "changeconfig to same URL as existing feed"
+make_rss20 $httpdir/feed.rss
+add "changeconfig true"
+add "feed 0 $httpurl/feed.rss"
+runs -u
+add "feed 0 $httpurl/301/feed.rss"
+rune "already subscribed" -u
+
+for state in false true; do
+       begin "changeconfig to URL of just-removed feed, splitstate $state"
+       make_rss20 $httpdir/feed.rss
+       add "splitstate $state"
+       add "changeconfig true"
+       add "feed 0 $httpurl/feed.rss"
+       runs -u
+       # Simulate the change failing, then succeeding.
+       for i in 1 2; do
+               : >$statedir/config
+               add "splitstate $state"
+               add "changeconfig true"
+               add "feed 0 $httpurl/301/feed.rss"
+               rune "has been updated automatically" -u
+               contains $statedir/config "$httpurl/feed.rss"
+               not_contains $statedir/config "$httpurl/301/feed.rss"
+       done
+       runs -u
+done
+
 begin "feed format text"
 make_rss20_desc $httpdir/feed.rss <<EOF
 three &lt; four, not HTML