From 183360b573717810238b25b28d464fafb1bf6e28 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 27 Aug 2026 02:46:52 -1000 Subject: Add tests for the plain page and the atom feed --- tests/t0111-atom.sh | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 tests/t0111-atom.sh (limited to 'tests/t0111-atom.sh') diff --git a/tests/t0111-atom.sh b/tests/t0111-atom.sh new file mode 100755 index 0000000..d2a678b --- /dev/null +++ b/tests/t0111-atom.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# The atom page serves a repository's recent history as a feed, XML rather +# than a page, so a reader can follow the project without polling the +# browsable log. These checks read the content type, count the entries +# against the max-atom-items cap, which defaults to ten, and hand the feed to +# xmllint where one is installed, since a reader is far stricter about +# well-formedness than any of the greps here. + +test_description='Check the atom feed' +. ./setup.sh + +test_expect_success 'generate foo/atom' ' + cgit_url "foo/atom" >tmp +' + +test_expect_success 'the response is an atom feed' ' + head -n 1 tmp | grep "Status: 200 OK" && + sed "/^$/q" tmp | grep "Content-Type: application/atom+xml" && + strip_headers feed && + grep "" feed && + grep "foo, branch master" feed +' + +test_expect_success 'every commit of a small repository is an entry' ' + test $(grep -c "" feed) -eq 5 && + grep "commit 1" feed && + grep "commit 5" feed +' + +test_expect_success 'ten entries is the default ceiling' ' + cgit_url "bar/atom" >tmp && + strip_headers feed && + test $(grep -c "" feed) -eq 10 && + grep "commit 50" feed && + ! grep "commit 40" feed +' + +test_expect_success 'max-atom-items overrides the ceiling' ' + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "max-atom-items=3" && + echo "repo.url=bar" && + echo "repo.path=$PWD/repos/bar/.git" + } >atomrc && + CGIT_CONFIG="$PWD/atomrc" QUERY_STRING="url=bar/atom" cgit >tmp && + strip_headers feed && + test $(grep -c "" feed) -eq 3 +' + +if command -v xmllint >/dev/null 2>&1 +then + test_set_prereq XMLLINT +else + say 'Skipping well-formedness check: xmllint not found' +fi + +test_expect_success XMLLINT 'the feed is well-formed xml' ' + cgit_url "foo/atom" >tmp && + strip_headers feed && + xmllint --noout feed +' + +test_done -- cgit v2.8.0