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/t0105-plain.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 tests/t0105-plain.sh (limited to 'tests/t0105-plain.sh') diff --git a/tests/t0105-plain.sh b/tests/t0105-plain.sh new file mode 100755 index 0000000..b950098 --- /dev/null +++ b/tests/t0105-plain.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# The plain page hands over a repository's own bytes rather than a rendered +# view of them, so these checks read the response headers and then compare +# the body against what git says the blob holds. A file with no better guess +# is served as text unless its bytes look binary, a directory answers with a +# bare listing of links rather than one of the themed pages, and a path that +# names nothing has to come back as a 404 rather than an empty document. + +test_description='Check content on plain page' +. ./setup.sh + +test_expect_success 'generate foo/plain/file-1' ' + cgit_url "foo/plain/file-1" >tmp +' + +test_expect_success 'a text file is served as text/plain' ' + head -n 1 tmp | grep "Status: 200 OK" && + sed "/^$/q" tmp | grep "Content-Type: text/plain" +' + +test_expect_success 'the body carries the blob byte for byte' ' + strip_headers body && + git -C repos/foo show master:file-1 >expect && + test_cmp expect body +' + +test_expect_success 'a missing path is a 404' ' + cgit_url "foo/plain/no-such-file" >tmp && + head -n 1 tmp | grep "Status: 404" +' + +test_expect_success 'a directory answers with a listing of links' ' + cgit_url "foo/plain" >tmp && + grep "
  • blob.bin && + git add blob.bin && + git commit -m binary + ) && + cgit_url "foo/plain/blob.bin" >tmp && + sed "/^$/q" tmp | grep "Content-Type: application/octet-stream" +' + +test_done -- cgit v2.8.0