Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Check the cache hook with remove_suffix set
Nothing ran the hook against a cache filled with remove-suffix=1, so
a hook that kept the .git on the url, and so dropped none of the pages
cgit had cached under the shorter one, passed.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0507-hooks.sh | 37 |
1 file changed, 37 insertions, 0 deletions
diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh index f578487..8da021f 100755 --- a/tests/t0507-hooks.sh +++ b/tests/t0507-hooks.sh @@ -81,6 +81,33 @@ test_expect_success 'set up a cache of two repositories and the index' ' grep -Fx "scan_path='\''$PWD/scan'\''" cache-hook ' +# With remove-suffix the url leaves out the .git the scan found, and the +# hook has to leave it out the same way. +test_expect_success 'set up a cache of repositories served without the suffix' ' + mkdir suffix-slots && + { + echo "cache-root=$PWD/suffix-slots" && + echo "cache-size=1000" && + echo "virtual-root=/" && + echo "remove-suffix=1" && + echo "scan-path=$PWD/scan" + } >suffixrc && + for page in / /a/ /a/log/ /b/ /b/log/ + do + CGIT_CONFIG="$PWD/suffixrc" PATH_INFO="$page" QUERY_STRING= cgit >/dev/null || + return 1 + done && + cp -R suffix-slots suffix-pristine && + cached_requests suffix-pristine >keys && + test_grep "|/a/log/0|" keys && + test_grep "|/b/log/0|" keys && + test_grep "|1|/0|" keys && + sed -e "s|^cache_root=.*|cache_root='\''$PWD/suffix-slots'\''|" \ + -e "s|^remove_suffix=.*|remove_suffix=1|" cache-hook >suffix-hook && + grep -Fx "cache_root='\''$PWD/suffix-slots'\''" suffix-hook && + grep -Fx "remove_suffix=1" suffix-hook +' + # The hooks are POSIX sh, so every case runs under each such shell that is # here. Whatever a hook prints reaches the pusher, so each has to stay # silent. @@ -106,6 +133,16 @@ do test_grep ! "^rc-" left-slots ' + test_expect_success "a push drops the pages of a repository served without the suffix under $shell" ' + rm -rf suffix-slots && cp -R suffix-pristine suffix-slots && + (cd scan/a.git && $shell ../../suffix-hook 2>../../err) && + test_must_be_empty err && + cached_requests suffix-slots >left && + test_grep "|/b/log/0|" left && + test_grep ! "|/a/" left && + test_grep ! "|1|/0|" left + ' + test_expect_success "a repository named in cgitrc gives the hook its url under $shell" ' fresh_slots && git -C scan/b.git config hooks.cgiturl b.git && |
