From 6f812eba8ef36bc846a56be61d1a77c6637b568f Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Tue, 3 Jul 2018 02:03:30 +0300 Subject: [PATCH] Add a test case which uses pup to check a listing --- t/04-hasindex-html.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 t/04-hasindex-html.test diff --git a/t/04-hasindex-html.test b/t/04-hasindex-html.test new file mode 100644 index 0000000..69ac222 --- /dev/null +++ b/t/04-hasindex-html.test @@ -0,0 +1,24 @@ +#! /bin/bash +cat <<--- +This test fetches the root directory served by Nginx, which has no index +file, and checks the output contains a few HTML elements know to exist in +a directory index. +-- +use pup +nginx_start + +content=$( fetch ) + +# Check page title +[[ $(pup -p title text{} <<< "${content}") = 'Index of /' ]] + +# Check table headers +[[ $(pup -n body table thead th a:first-child <<< "${content}") -eq 3 ]] +{ + read -r name_label + read -r size_label + read -r date_label +} < <( pup -p body table thead th a:first-child text{} <<< "${content}" ) +[[ ${name_label} = File\ Name ]] +[[ ${size_label} = File\ Size ]] +[[ ${date_label} = Date ]]