From fa13aef31b4d663d081a9b0eb8649357fb44de32 Mon Sep 17 00:00:00 2001 From: kPherox Date: Mon, 15 Oct 2018 14:41:01 +0900 Subject: [PATCH] Add test for `fancyindex_hide_parent_dir on` --- .gitignore | 3 +++ t/06-hide_parent.test | 23 +++++++++++++++++++++++ t/child-directory/empty-file.txt | 0 3 files changed, 26 insertions(+) create mode 100644 t/06-hide_parent.test create mode 100644 t/child-directory/empty-file.txt diff --git a/.gitignore b/.gitignore index 67d2c48..2ac2356 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ /t/*.sh /t/*.out /t/*.err +/t/pup* +/t/bug*/ +/prefix/ diff --git a/t/06-hide_parent.test b/t/06-hide_parent.test new file mode 100644 index 0000000..494c958 --- /dev/null +++ b/t/06-hide_parent.test @@ -0,0 +1,23 @@ +#! /bin/bash +cat <<--- +This test check the output using "fancyindex_hide_parent_dir on" +-- +use pup +nginx_start 'fancyindex_hide_parent_dir on;' + +content=$( fetch /child-directory/ ) + +# Check page title +[[ $(pup -p title text{} <<< "${content}") = "Index of /child-directory/" ]] + +# Check table headers +[[ $(pup -n body table tbody tr:first-child td <<< "${content}") -eq 3 ]] +{ + read -r name_label + read -r size_label + read -r date_label +} < <( pup -p body table tbody tr:first-child td text{} <<< "${content}" ) +[[ ${name_label} != Parent\ Directory/ ]] +[[ ${name_label} = empty-file.txt ]] +[[ ${size_label} != - ]] +[[ ${date_label} != - ]] diff --git a/t/child-directory/empty-file.txt b/t/child-directory/empty-file.txt new file mode 100644 index 0000000..e69de29