From e32c1a72d891be92ca5d8431b8b769f08202d36d Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Thu, 19 Jan 2023 20:51:08 +0200 Subject: [PATCH] Add missing entry in long weekday names array The entry for Saturday was missing, as pointed out in the bug report. While at it, add a test case. Fixes #157 --- ngx_http_fancyindex_module.c | 2 +- t/bug157-saturday-in-long-weekdays.test | 27 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 t/bug157-saturday-in-long-weekdays.test diff --git a/ngx_http_fancyindex_module.c b/ngx_http_fancyindex_module.c index bfccdc8..ed349d5 100644 --- a/ngx_http_fancyindex_module.c +++ b/ngx_http_fancyindex_module.c @@ -37,7 +37,7 @@ static const char *short_weekday[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", }; static const char *long_weekday[] = { - "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Sunday", + "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", }; static const char *short_month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", diff --git a/t/bug157-saturday-in-long-weekdays.test b/t/bug157-saturday-in-long-weekdays.test new file mode 100644 index 0000000..a2a0f6c --- /dev/null +++ b/t/bug157-saturday-in-long-weekdays.test @@ -0,0 +1,27 @@ +#! /bin/bash +cat <<--- +Check whether the Saturday long day name is available. +https://github.com/aperezdc/ngx-fancyindex/issues/157 +-- +use pup +nginx_start 'fancyindex_time_format "%A"; fancyindex_default_sort date;' + +mkdir -p "${TESTDIR}/weekdays" +for (( i=2 ; i <= 8 ; i++ )) ; do + TZ=UTC touch -d "2023-01-0${i}T06:00:00" "${TESTDIR}/weekdays/day$i.txt" +done +ls "${TESTDIR}/weekdays" +content=$(fetch /weekdays/) + +# We need row+1 because the first one is the table header. +dayname=$(pup -p body table tbody \ + 'tr:nth-child(7)' 'td:nth-child(3)' 'text{}' \ + <<< "$content") +[[ $dayname = Saturday ]] || fail 'Sixth day is not Saturday' + +dayname=$(pup -p body table tbody \ + 'tr:nth-child(8)' 'td:nth-child(3)' 'text{}' \ + <<< "$content") +[[ $dayname = Sunday ]] || fail 'Seventh day is not Sunday' + +nginx_is_running || fail 'Nginx died'