From e49a38408a7103bc509c7c185359f1a9eaa20c28 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 17:39:32 -1000 Subject: Move the mimetype file tests to the plain tests Each now writes a types file and config of its own rather than rewriting the one the test before it left. --- tests/t0105-plain.sh | 23 +++++++++++++++++++++++ tests/t0303-robustness.sh | 22 ---------------------- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/t0105-plain.sh b/tests/t0105-plain.sh index 68832da..e06ec96 100755 --- a/tests/t0105-plain.sh +++ b/tests/t0105-plain.sh @@ -209,4 +209,27 @@ test_expect_success 'a control character in a file name stays out of the headers grep "^Content-Disposition: inline; filename=.ctl?name.txt.$" tmp ' + +# A mime.types file gives an extension the type of the first line naming it, +# so a line naming nothing, or a comment naming the extension ahead of the +# real line, has to be passed over. Each test writes a file of its own. +test_expect_success 'set up a file whose type only a mimetype file knows' ' + test_create_repo repos/mime && + test_commit -C repos/mime --no-tag note note.cgt +' + +test_expect_success 'a blank line in the mimetype file is skipped' ' + printf "\n \nimage/x-cgit cgt\n" >blank.types && + cgitrc_repo blankrc mime "mimetype-file=$PWD/blank.types" && + cgit_ok blankrc "url=mime/plain/note.cgt" >tmp && + grep "^Content-Type: image/x-cgit$" tmp +' + +test_expect_success 'an indented comment in the mimetype file is skipped' ' + printf " # cgt used to be image/x-old\nimage/x-cgit cgt\n" >comment.types && + cgitrc_repo commentrc mime "mimetype-file=$PWD/comment.types" && + cgit_ok commentrc "url=mime/plain/note.cgt" >tmp && + grep "^Content-Type: image/x-cgit$" tmp +' + test_done diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index d9a8809..7fa06da 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -528,28 +528,6 @@ test_expect_success 'the fallback branch skips a name spelled like an option' ' test_grep ! "