Skip to content

Commit 1b0f5f7

Browse files
committed
adding test for #3
1 parent 68352bc commit 1b0f5f7

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

tests-ng/test-nested-same-name.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
# author: deadc0de6 (https://github.com/deadc0de6)
3+
# Copyright (c) 2024, deadc0de6
4+
#
5+
# test for nested directories with same names
6+
# for https://github.com/deadc0de6/gocatcli/issues/3
7+
#
8+
9+
## start-test-cookie
10+
set -eu -o errtrace -o pipefail
11+
cur=$(cd "$(dirname "${0}")" && pwd)
12+
bin="${cur}/../bin/gocatcli"
13+
[ ! -e "${bin}" ] && echo "\"${bin}\" not found" && exit 1
14+
# shellcheck disable=SC1091
15+
source "${cur}"/helpers
16+
## end-test-cookie
17+
18+
######################################
19+
## the test
20+
21+
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
22+
tmpx=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d)
23+
clear_on_exit "${tmpd}"
24+
clear_on_exit "${tmpx}"
25+
26+
catalog="${tmpd}/catalog"
27+
out="${tmpd}/output.txt"
28+
29+
# create hierarchy
30+
top="${tmpx}/top"
31+
sup="${top}/artist"
32+
sub="${sup}/artist"
33+
subf="${sub}/sub-file"
34+
supf="${sup}/sup-file"
35+
topf="${top}/top-file"
36+
mkdir -p "${sub}"
37+
echo "sub-file" > "${subf}"
38+
echo "sup-file" > "${supf}"
39+
echo "top-file" > "${topf}"
40+
41+
# index
42+
echo ">>> index dir <<<"
43+
"${bin}" index -a -C --debug -c "${catalog}" --ignore=".git" "${top}" top
44+
[ ! -e "${catalog}" ] && echo "catalog not created" && exit 1
45+
46+
# ls
47+
echo ">>> ls catalog <<<"
48+
"${bin}" -c "${catalog}" ls -a -r | sed -e 's/\x1b\[[0-9;]*m//g' | sed 's/[[:space:]]*$//' > "${out}"
49+
50+
cat > "${tmpx}/expected" << _EOF
51+
storage top
52+
artist
53+
artist
54+
sub-file
55+
sup-file
56+
top-file
57+
_EOF
58+
59+
if hash delta >/dev/null 2>&1; then
60+
delta "${tmpx}/expected" "${out}"
61+
else
62+
diff -w --suppress-common-lines "${tmpx}/expected" "${out}"
63+
fi
64+
65+
echo "test $(basename "${0}") OK!"
66+
exit 0

0 commit comments

Comments
 (0)