diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Add a test suite for the shipped extensions
Diffstat (limited to 'tests/t0503-link-commits.sh')
| -rwxr-xr-x | tests/t0503-link-commits.sh | 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 60 insertions, 0 deletions
diff --git a/tests/t0503-link-commits.sh b/tests/t0503-link-commits.sh new file mode 100755 index 0000000..11b1b54 --- /dev/null +++ b/tests/t0503-link-commits.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +# Checks link-commits.lua, the shipped commit-filter, whose configuration as +# shipped links bare object names to ./?id= and issue marks like #123 to +# bugs.example.com. The unit checks cover the matching rules under every +# suitable standalone Lua, and a commit whose message carries one of each is +# then rendered through cgit itself. + +test_description='Check the shipped link-commits extension' +CGIT_TEST_NO_CREATE_REPOS=YesPlease +. ./setup.sh +. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh" + +interpreters=$(ext_lua_interpreters 4) +test -z "$interpreters" && + say 'no standalone lua on the path, unit checks skipped' + +for lua in $interpreters +do + test_expect_success "unit checks under $lua" " + '$lua' '$EXT_TEST_DIRECTORY/test-link-commits.lua' \ + '$EXTENSIONS_DIRECTORY/link-commits.lua' + " +done + +test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA +test "$CGIT_HAS_LUA" -eq 1 || + say 'cgit built without lua, filter checks through cgit skipped' + +test_expect_success 'create a repository whose commit message holds matches' ' + test_create_repo repos/linky && + ( + cd repos/linky && + echo content >file && + git add file && + git commit -m "fix #123 near deadbeefcafe1234" + ) +' + +test_expect_success 'point cgit at it through the commit filter' ' + cat >cgitrc <<-EOF + virtual-root=/ + cache-size=0 + enable-filter-overrides=1 + repo.url=linky + repo.path=$PWD/repos/linky/.git + repo.commit-filter=lua:$EXTENSIONS_DIRECTORY/link-commits.lua + EOF +' + +test_expect_success CGIT_LUA 'the issue mark links out on the commit page' ' + cgit_url "linky/commit/" >tmp && + grep "bugs.example.com/?bug=123.>#123</a>" tmp +' + +test_expect_success CGIT_LUA 'the object name links to its own page' ' + grep "id=deadbeefcafe1234.>deadbeefcafe1234</a>" tmp +' + +test_done |
