aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-07-04 09:36:31 +0000
committerOmar Polo <op@omarpolo.com>2022-07-04 09:36:31 +0000
commit475205fa0f2737475a17dd692b71611523b898a0 (patch)
tree0e98e5df0789efb3d160c497ffb3311866520ec1
parentddd3c5529f58fc4dffe30c642ef1df7eee5ae2ec (diff)
check for the expected page in test_auto_index
not just the number of lines, check the full page!
-rw-r--r--regress/Makefile1
-rw-r--r--regress/tests.sh27
2 files changed, 18 insertions, 10 deletions
diff --git a/regress/Makefile b/regress/Makefile
index 8408870..e0a671a 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -81,6 +81,7 @@ testdata: fill-file
cp hello slow err invalid serve-bigfile env testdata/
cp max-length-reply testdata
mkdir testdata/dir
+ date > 'testdata/dir/current date'
cp hello testdata/dir
cp testdata/index.gmi testdata/dir/foo.gmi
touch testdata/test.m3u8 testdata/foo.1
diff --git a/regress/tests.sh b/regress/tests.sh
index 41839d3..5ad78ac 100644
--- a/regress/tests.sh
+++ b/regress/tests.sh
@@ -171,20 +171,27 @@ test_auto_index() {
check_reply "30 /dir/" || return 1
fetch_hdr /dir/
- check_reply "20 text/gemini"
+ check_reply "20 text/gemini" || return 1
- # we expect 5 lines from the auto index
+ get /dir/ > listing || return 1
+ cat <<EOF > listing.expected
+# Index of /dir/
- body="$(get /dir/ | count)"
- if [ $? -ne 0 ]; then
- echo 'failed to get /dir/'
- return 1
- fi
+=> ./..
+=> ./current%20date
+=> ./foo.gmi
+=> ./hello
+EOF
- if [ "$body" -ne 5 ]; then
- echo "expected five lines from the auto index, got $body"
- return 1
+ cmp -s listing.expected listing
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo 'unexpected dir content:'
+ diff -u listing.expected listing
fi
+ rm listing listing.expected
+
+ return $ret
}
test_block() {