File: 07-directory-first.test

package info (click to toggle)
libnginx-mod-http-fancyindex 1%3A0.5.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 340 kB
  • sloc: ansic: 1,296; sh: 588; awk: 36; makefile: 3
file content (50 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/bash
cat <<---
This test check the output using "fancyindex_directories_first on"
--
use pup

for d in "008d" "000d" "004d" ; do
	mkdir -p "${TESTDIR}/dir_first/${d}"
done
for f in "005f" "001f" "003f"; do
	touch "${TESTDIR}/dir_first/${f}"
done
for d in "006d" "002d" ; do
	mkdir -p "${TESTDIR}/dir_first/${d}"
done

nginx_start 'fancyindex_directories_first on;'
previous=''
cur_type=''
while read -r name ; do
	case "$name" in
	*Parent*)
		;;
	*d*)
		echo "dir $name"
		[[ "$cur_type" = f ]] && fail 'Directories should come before Files'
		cur_type=d
		if [[ -z ${previous} ]] ; then
			previous=${name}
		else
			[[ ${previous} < ${name} ]] || fail \
				'Name %s should come before %s\n' "${previous}" "${name}"
		fi
		;;
	*f*)
		echo "file $name"
		[[ -z "$cur_type" ]] && fail 'Directories should come before Files'
		if [[ "$cur_type" = d ]] ; then
			cur_type=f
			previous=${name}
		else
			[[ ${previous} < ${name} ]] || fail \
				'Name %s should come before %s\n' "${previous}" "${name}"
		fi
		;;
	esac
done < <( fetch '/dir_first/' \
		| pup -p body table tbody 'td:nth-child(1)' text{} )

nginx_is_running || fail "Nginx died"