sfeed_update: convertencoding test and improvements - 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 26d3f20af23c9374e58f9eb51cc8cbe05041ee85
(DIR) parent 169b3ffdd7096e5fe0df2475e849b2bac8e6c757
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Thu, 28 Dec 2023 12:33:52 +0100
sfeed_update: convertencoding test and improvements
Diffstat:
M input/sfeed_update/test.sh | 84 +++++++++++++++++++++----------
1 file changed, 58 insertions(+), 26 deletions(-)
---
(DIR) diff --git a/input/sfeed_update/test.sh b/input/sfeed_update/test.sh
@@ -1,5 +1,9 @@
#!/bin/sh
+# TODO:
+# - test proper cleanup on SIGTERM.
+# - test parameters and contents when overriding functions.
+
SFEED_UPDATE="sfeed_update"
# expect(expect, got, [extra])
@@ -444,39 +448,75 @@ feeds() {
echo "test_override_fetch: test OK" >&2
}
-# TODO
test_override_convertencoding() {
init_test
+ paramfile="$(mktemp /tmp/convertencoding_param_XXXXXXXX)"
+
createrc > "$rc" <<!
sfeedpath="$feedpath"
+maxjobs=1
+
+fetch() {
+ echo
+}
+
+parse() {
+ cat
+}
# convertencoding(name, from, to)
convertencoding() {
- # TODO: check parameters also
+ printf '%s|%s|%s|\n' "\$1" "\$2" "\$3" >> "$paramfile"
+
+ # to parameter is always "utf-8".
+ test "\$3" != "utf-8" && return 1
case "\$1" in
1)
- echo "<item><title>a</title></item>";;
+ echo "a";;
2)
- echo "<item><title>b</title></item>";;
+ echo "b";;
3)
- echo "<item><title>c</title></item>";;
+ echo "c";;
+ 4)
+ echo "d";;
+ 5)
+ echo "e";;
esac
}
feeds() {
# feed <name> <feedurl> [basesiteurl] [encoding]
- feed "1" "file:///dev/null" "" "utf-8"
- feed "2" "file:///dev/null" "" "utf-69"
- feed "3" "file:///dev/null" "" "iso-8859-1"
+ feed "1" "file:///dev/null1" "" ""
+ feed "2" "file:///dev/null2" "" "utf-8"
+ feed "3" "file:///dev/null3" "" "iso-8859-1"
+ feed "4" "file:///dev/null4" "" "utf-69"
+ feed "5" "file:///dev/null5" "" "from-utf-6"
}
!
"$SFEED_UPDATE" "$rc" >"$log_stdout" 2>"$log_stderr"
- # TODO: check results.
+ expect "0" "$?" "exit statuscode"
+
+ linecount=$(wc -l < "$log_stdout")
+ linecount=$((linecount+0))
+ expect "5" "$linecount" "5 lines should be written to stdout"
- ls -l "$feedpath" # DEBUG
+ linecount=$(wc -l < "$log_stderr")
+ linecount=$((linecount+0))
+ expect "0" "$linecount" "0 line should be written to stderr"
+
+ result=$(cut -f 2 "$feedpath/1" "$feedpath/2" "$feedpath/3" \
+ "$feedpath/4" "$feedpath/5" | tr -d '\n')
+ expect "abcde" "$result" "results of feed files"
+
+ paramstr=$(cat "$paramfile" | tr -d '\n')
+ expect '1||utf-8|2|utf-8|utf-8|3|iso-8859-1|utf-8|4|utf-69|utf-8|5|from-utf-6|utf-8|'\
+ "$paramstr" "test parameters"
+
+ cleanup
+ rm -f "$paramfile"
echo "test_override_convertencoding: test OK" >&2
}
@@ -833,22 +873,12 @@ feeds() {
echo "test_fail_order: test OK" >&2
}
-# TODO
-test_override_cleanup
-test_override_fetch
-
-#test_override_convertencoding
+# TODO: test parameters and contents when overriding functions
#test_override_parse
#test_override_filter
#test_override_merge
#test_override_order
-
-# TODO:
-
-
-
-exit 0
-
+#exit 0
test_normal
test_one_fail
@@ -866,9 +896,11 @@ test_fail_order
test_nothing_to_merge
+test_override_cleanup
+test_override_fetch
+test_override_convertencoding
+
+echo "Testing SIGTERM (has some delay)..."
+
# NOTE: SIGINT can't reliably be tested.
test_sigterm
-
-# TODO:
-# - test proper cleanup on SIGTERM.
-# - test override functions.