sfeed_update: test merge and order, also when there is nothing to merge - sfeed_tests - sfeed tests and RSS and Atom files
(HTM) git clone git://git.codemadness.org/sfeed_tests
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit dc8fa93e7c68261a0996dcb0b757ad3a0867e1b2
(DIR) parent 723812cc3ee55eb5a851ab142a918bde8b517cdc
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Thu, 28 Dec 2023 11:43:37 +0100
sfeed_update: test merge and order, also when there is nothing to merge
Diffstat:
M input/sfeed_update/test.sh | 78 +++++++++++++++++++++++++++----
1 file changed, 68 insertions(+), 10 deletions(-)
---
(DIR) diff --git a/input/sfeed_update/test.sh b/input/sfeed_update/test.sh
@@ -592,6 +592,60 @@ feeds() {
echo "test_fail_filter: test OK" >&2
}
+test_nothing_to_merge() {
+ init_test
+
+ createrc > "$rc" <<!
+sfeedpath="$feedpath"
+maxjobs=1
+
+# filter must output some data, otherwise there is nothing to merge.
+#filter() {
+# echo a
+#}
+
+merge() {
+ test "\$1" = "2" && return 1
+ return 0
+}
+
+feeds() {
+ # feed <name> <feedurl> [basesiteurl] [encoding]
+ feed "1" "file:///dev/null"
+ feed "2" "file:///dev/null"
+ feed "3" "file:///dev/null"
+}
+!
+
+ # feed 2 isn't called (nothing to merge) so should return exit 0.
+ "$SFEED_UPDATE" "$rc" >"$log_stdout" 2> "$log_stderr"
+ expect "0" "$?" "exit statuscode"
+
+ linecount=$(wc -l < "$log_stdout")
+ linecount=$((linecount+0))
+ expect "3" "$linecount" "3 lines should be written to stdout"
+
+ linecount=$(wc -l < "$log_stderr")
+ linecount=$((linecount+0))
+ expect "0" "$linecount" "0 line should be written to stderr"
+
+ grep -q "] 2 .* FAIL (MERGE)" < "$log_stderr"
+ expect "1" "$?" 'stderr should not contain "FAIL (MERGE)"'
+
+ test -d "$feedpath"
+ expect "0" "$?" "directory should exist: $feedpath"
+
+ for i in 1 2 3; do
+ f="$feedpath/$i"
+ test -f "$f"
+ expect "0" "$?" "file should exist: $f"
+ done
+
+ cleanup
+
+ echo "test_nothing_to_merge: test OK" >&2
+}
+
test_fail_merge() {
init_test
@@ -599,9 +653,14 @@ test_fail_merge() {
sfeedpath="$feedpath"
maxjobs=1
+# filter must output some data, otherwise there is nothing to merge.
+filter() {
+ echo a
+}
+
merge() {
test "\$1" = "2" && return 1
- true
+ return 0
}
feeds() {
@@ -623,9 +682,6 @@ feeds() {
linecount=$((linecount+0))
expect "1" "$linecount" "1 line should be written to stderr"
- # TODO: test both if there is new data (after filter stage) and no data.
- # because if theres no data theres not even a merge attempted.
-
grep -q "] 2 .* FAIL (MERGE)" < "$log_stderr"
expect "0" "$?" 'stderr should contain "FAIL (MERGE)"'
@@ -650,7 +706,12 @@ test_fail_order() {
sfeedpath="$feedpath"
maxjobs=1
+# filter must output some data, otherwise there is nothing to merge.
filter() {
+ echo a
+}
+
+order() {
test "\$1" = "2" && return 1
true
}
@@ -674,9 +735,6 @@ feeds() {
linecount=$((linecount+0))
expect "1" "$linecount" "1 line should be written to stderr"
- # TODO: test both if there is new data (after filter stage) and no data.
- # because if theres no data theres not even a merge attempted.
-
grep -q "] 2 .* FAIL (ORDER)" < "$log_stderr"
expect "0" "$?" 'stderr should contain "FAIL (ORDER)"'
@@ -712,10 +770,10 @@ test_fail_fetch
test_fail_convertencoding
test_fail_parse
test_fail_filter
+test_fail_merge
+test_fail_order
-# TODO
-#test_fail_merge
-#test_fail_order
+test_nothing_to_merge
# NOTE: SIGINT can't reliably be tested.
test_sigterm