From ea0925d4fea4fb75049da3f60048de1b643851e9 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 08:54:55 -1000 Subject: Test that only full ids take the static ttl Nothing requested a page pinned to an id with the static ttl in force, so dropping the full id check would cache a page pinned to master or an abbreviation for ever and the suite would pass. --- tests/t0003-cache.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index 5e8245b..9ae13ac 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -230,6 +230,31 @@ test_expect_success 'pages following a branch take the dynamic ttl' ' test_line_count = 2 summary.slots ' +# Only a full object id names a page that can never change, so a page pinned +# to one alone takes the static ttl, which by default never expires. An +# abbreviation or a branch name, in either id, can come to mean another +# commit. +test_expect_success 'only a page pinned to full ids takes the static ttl' ' + rm -rf cache3 && mkdir cache3 && + { + echo "cache-dynamic-ttl=0" && + cat bigkeyrc + } >staticrc && + first=$(git -C repos/bigpage rev-parse HEAD~1) && + short=$(git -C repos/bigpage rev-parse --short HEAD~1) && + for query in "commit/&id=$short" "commit/&id=master" "diff/&id=$first&id2=$short" "diff/&id=master&id2=$first" + do + cgit_ok staticrc "url=bigpage/$query" >/dev/null || return 1 + done && + test_dir_is_empty cache3 && + cgit_ok staticrc "url=bigpage/commit/&id=$first" >/dev/null && + ls cache3 >static.slots && + test_line_count = 1 static.slots && + cgit_ok staticrc "url=bigpage/diff/&id=$first&id2=$first" >/dev/null && + ls cache3 >static.slots && + test_line_count = 2 static.slots +' + # 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