From: Mark Jamsek Subject: gotwebd: basic regress for blame and tree actions To: gameoftrees@openbsd.org Date: Mon, 25 Nov 2024 20:58:55 +1100 As per the subject: add a couple basic tests for blame and tree actions. commit 6154959ee238757aca654812f1a4ce08eb519a9a (main) from: Mark Jamsek date: Mon Nov 25 09:33:05 2024 UTC gotwebd: basic blame and tree action regress tests A regress/gotwebd/action_blame.html | 7+ 0- A regress/gotwebd/action_tree.html | 6+ 0- M regress/gotwebd/test_gotwebd.sh | 57+ 0- 3 files changed, 70 insertions(+), 0 deletions(-) commit - 79fb6b19d76a47994da552e11d60ade52ae524dd commit + 6154959ee238757aca654812f1a4ce08eb519a9a blob - /dev/null blob + aab925b8016a488419bc22269b98624b2f70ea2a (mode 644) --- /dev/null +++ regress/gotwebd/action_blame.html @@ -0,0 +1,7 @@ +Content-Security-Policy: default-src 'self'; script-src 'none'; object-src 'none'; +Content-Type: text/html + +Gotweb

Blame


1 ${COMMIT_ID8} ${COMMIT_YMD} ${COMMITTER} alpha +

Got Owner

blob - /dev/null blob + 04128f4bdb98962d74f179c4849e04da560b5bec (mode 644) --- /dev/null +++ regress/gotwebd/action_tree.html @@ -0,0 +1,6 @@ +Content-Security-Policy: default-src 'self'; script-src 'none'; object-src 'none'; +Content-Type: text/html + +Gotweb

Tree


alphacommits | blame
betacommits | blame
epsilon/
gamma/

Got Owner

blob - 835f0a599f14f193c79d96780f45c2df410e6988 blob + f585c07b32722294e8e10ab951a1f41825e83fcf --- regress/gotwebd/test_gotwebd.sh +++ regress/gotwebd/test_gotwebd.sh @@ -73,6 +73,63 @@ test_gotwebd_action_commit() test_done "$testroot" "$repo" "$ret" } +test_gotwebd_action_blame() +{ + local testroot=$(test_init gotwebd_action_blame 1) + local repo="${GOTWEBD_TEST_CHROOT}/got/public/repo.git" + local id=$(git_show_head $repo) + local author_time=$(git_show_author_time $repo) + local qs="action=blame&commit=${id}&file=alpha&folder=&path=repo.git" + + COMMIT_ID=$id \ + COMMITTER="flan_hack" \ + COMMIT_ID8=$(printf '%.8s' $id) \ + COMMIT_YMD=$(date -u -r $author_time +"%F") \ + COMMIT_YMDHMS=$(date -u -r $author_time +"%FT%TZ") \ + COMMIT_DATE=$(date -u -r $author_time +"%a %b %e %X %Y") \ + interpolate action_blame.html > $testroot/content.expected + + $GOTWEBD_TEST_FCGI -q "$qs" > $testroot/content + + cmp -s $testroot/content.expected $testroot/content + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/content.expected $testroot/content + test_done "$testroot" "$repo" "$ret" + return 1 + fi + + test_done "$testroot" "$repo" "$ret" +} + +test_gotwebd_action_tree() +{ + local testroot=$(test_init gotwebd_action_tree 1) + local repo="${GOTWEBD_TEST_CHROOT}/got/public/repo.git" + local author_time=$(git_show_author_time $repo) + local qs="action=tree&path=repo.git" + + COMMIT_ID=$(git_show_head $repo) \ + COMMIT_YMDHMS=$(date -u -r $author_time +"%FT%TZ") \ + COMMIT_DATE=$(date -u -r $author_time +"%a %b %e %X %Y") \ + TREE_ID=$(got cat -r $repo main | head -1 | cut -d ' ' -f2) \ + interpolate action_tree.html > $testroot/content.expected + + $GOTWEBD_TEST_FCGI -q "$qs" > $testroot/content + + cmp -s $testroot/content.expected $testroot/content + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/content.expected $testroot/content + test_done "$testroot" "$repo" "$ret" + return 1 + fi + + test_done "$testroot" "$repo" "$ret" +} + test_parseargs "$@" run_test test_gotwebd_action_index run_test test_gotwebd_action_commit +run_test test_gotwebd_action_blame +run_test test_gotwebd_action_tree -- Mark Jamsek GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68