check for the expected page in test_auto_index

not just the number of lines, check the full page!
This commit is contained in:
Omar Polo 2022-07-04 09:36:31 +00:00
parent ddd3c5529f
commit 475205fa0f
2 changed files with 18 additions and 10 deletions

View File

@ -81,6 +81,7 @@ testdata: fill-file
cp hello slow err invalid serve-bigfile env testdata/ cp hello slow err invalid serve-bigfile env testdata/
cp max-length-reply testdata cp max-length-reply testdata
mkdir testdata/dir mkdir testdata/dir
date > 'testdata/dir/current date'
cp hello testdata/dir cp hello testdata/dir
cp testdata/index.gmi testdata/dir/foo.gmi cp testdata/index.gmi testdata/dir/foo.gmi
touch testdata/test.m3u8 testdata/foo.1 touch testdata/test.m3u8 testdata/foo.1

View File

@ -171,20 +171,27 @@ test_auto_index() {
check_reply "30 /dir/" || return 1 check_reply "30 /dir/" || return 1
fetch_hdr /dir/ 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 => ./current%20date
echo 'failed to get /dir/' => ./foo.gmi
return 1 => ./hello
EOF
cmp -s listing.expected listing
ret=$?
if [ $ret -ne 0 ]; then
echo 'unexpected dir content:'
diff -u listing.expected listing
fi fi
rm listing listing.expected
if [ "$body" -ne 5 ]; then return $ret
echo "expected five lines from the auto index, got $body"
return 1
fi
} }
test_block() { test_block() {