diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Deduplicate the cache test request lists
-rwxr-xr-xtests/t0003-cache.sh73
1 file changed, 25 insertions, 48 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh
index ca85d97..7ad2a79 100755
--- a/tests/t0003-cache.sh
+++ b/tests/t0003-cache.sh
@@ -10,68 +10,45 @@
test_description='Validate cache'
. ./setup.sh
-test_expect_success 'verify cache-size=0' '
+# The three counting tests below visit the same pages, the index plus six
+# pages in each of two repositories, so the counts they expect stay tied to
+# this one list of thirteen requests.
+request_all_pages() {
+ cgit_url "" &&
+ for repo in foo bar
+ do
+ for page in "" /refs /tree /log /diff /patch
+ do
+ cgit_url "$repo$page" || return 1
+ done
+ done
+}
+set_cache_size() {
+ sed -e "s/^cache-size=.*$/cache-size=$1/" cgitrc >cgitrc.tmp &&
+ mv -f cgitrc.tmp cgitrc
+}
+
+test_expect_success 'verify cache-size=0' '
rm -f cache/* &&
- sed -e "s/cache-size=1021$/cache-size=0/" cgitrc >cgitrc.tmp &&
- mv -f cgitrc.tmp cgitrc &&
- cgit_url "" &&
- cgit_url "foo" &&
- cgit_url "foo/refs" &&
- cgit_url "foo/tree" &&
- cgit_url "foo/log" &&
- cgit_url "foo/diff" &&
- cgit_url "foo/patch" &&
- cgit_url "bar" &&
- cgit_url "bar/refs" &&
- cgit_url "bar/tree" &&
- cgit_url "bar/log" &&
- cgit_url "bar/diff" &&
- cgit_url "bar/patch" &&
+ set_cache_size 0 &&
+ request_all_pages &&
ls cache >output &&
test_line_count = 0 output
'
test_expect_success 'verify cache-size=1' '
-
rm -f cache/* &&
- sed -e "s/cache-size=0$/cache-size=1/" cgitrc >cgitrc.tmp &&
- mv -f cgitrc.tmp cgitrc &&
- cgit_url "" &&
- cgit_url "foo" &&
- cgit_url "foo/refs" &&
- cgit_url "foo/tree" &&
- cgit_url "foo/log" &&
- cgit_url "foo/diff" &&
- cgit_url "foo/patch" &&
- cgit_url "bar" &&
- cgit_url "bar/refs" &&
- cgit_url "bar/tree" &&
- cgit_url "bar/log" &&
- cgit_url "bar/diff" &&
- cgit_url "bar/patch" &&
+ set_cache_size 1 &&
+ request_all_pages &&
ls cache >output &&
test_line_count = 1 output
'
test_expect_success 'verify cache-size=1021' '
-
rm -f cache/* &&
- sed -e "s/cache-size=1$/cache-size=1021/" cgitrc >cgitrc.tmp &&
- mv -f cgitrc.tmp cgitrc &&
- cgit_url "" &&
- cgit_url "foo" &&
- cgit_url "foo/refs" &&
- cgit_url "foo/tree" &&
- cgit_url "foo/log" &&
- cgit_url "foo/diff" &&
- cgit_url "foo/patch" &&
- cgit_url "bar" &&
- cgit_url "bar/refs" &&
- cgit_url "bar/tree" &&
- cgit_url "bar/log" &&
- cgit_url "bar/diff" &&
- cgit_url "bar/patch" &&
+ set_cache_size 1021 &&
+ request_all_pages &&
ls cache >output &&
test_line_count = 13 output &&
cgit_url "foo/ls_cache" >output.full &&