From 005034937156c5bd1f6e65491f8d7f95008e50c7 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 19:03:34 -1000 Subject: Test that each page ttl of 0 leaves its page out cache-about-ttl and cache-snapshot-ttl were never set, cache-index-ttl only by the way and cache-summary-ttl only elsewhere at 0, so a page that took the wrong ttl, or a setting that was never read, passed. --- tests/t0003-cache.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests') diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index 749ca97..c1b5163 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -342,6 +342,37 @@ test_expect_success 'only a page pinned to full ids takes the static ttl' ' test_line_count = 2 static.slots ' +# Each kind of page takes a ttl of its own, and a ttl of 0 keeps that page out +# of the cache. The same page with its ttl at 1 fills a slot, so the empty +# cache-root is down to the 0 rather than to a page that is never cached. +test_expect_success 'a page ttl of 0 leaves that page uncached' ' + first=$(git -C repos/bigpage rev-parse HEAD~1) && + while read setting query + do + rm -rf cache3 && mkdir cache3 && + { + echo "snapshots=tar.gz" && + echo "$setting=0" && + cat bigkeyrc && + echo "repo.readme=:file-1" + } >ttl0rc && + sed "/^$setting=/s/=0/=1/" ttl0rc >ttl1rc && + cgit_ok ttl0rc "url=$query" >/dev/null && + test_dir_is_empty cache3 && + cgit_ok ttl1rc "url=$query" >/dev/null && + ls cache3 >ttl.slots && + test_line_count = 1 ttl.slots || + { echo "$setting does not govern url=$query" && return 1; } + done <<-EOF + cache-index-ttl + cache-summary-ttl bigpage/ + cache-about-ttl bigpage/about/ + cache-snapshot-ttl bigpage/snapshot/master.tar.gz + cache-static-ttl bigpage/commit/&id=$first + cache-dynamic-ttl bigpage/log/ + EOF +' + # A write into the lock file that fails on the page's last flush has to end # as one that fails mid page does, with the fill abandoned and the page # delivered from the lock file, rather than in a blank response. The limit -- cgit 2.12.1