"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
gotwebd: basic regress for blame and tree actions
To:
gameoftrees@openbsd.org
Date:
Mon, 25 Nov 2024 20:58:55 +1100

Download raw body.

Thread
As per the subject: add a couple basic tests for blame and tree actions.

commit 6154959ee238757aca654812f1a4ce08eb519a9a (main)
from: Mark Jamsek <mark@jamsek.dev>
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
+
+<!doctype html><html><head><meta charset="utf-8" /><title>Gotweb</title><meta name="viewport" content="initial-scale=1.0" /><meta name="msapplication-TileColor" content="#da532c" /><meta name="theme-color" content="#ffffff"/><link rel="apple-touch-icon" sizes="180x180" href="/gotwebd_test_harness/apple-touch-icon.png" /><link rel="icon" type="image/png" sizes="32x32" href="/gotwebd_test_harness/favicon-32x32.png" /><link rel="icon" type="image/png" sizes="16x16" href="/gotwebd_test_harness/favicon-16x16.png" /><link rel="manifest" href="/gotwebd_test_harness/site.webmanifest"/><link rel="mask-icon" href="/gotwebd_test_harness/safari-pinned-tab.svg" /><link rel="stylesheet" type="text/css" href="/gotwebd_test_harness/gotweb.css" /></head><body><header id="header"><div id="got_link"><a href="https://gameoftrees.org" target="_blank"><img src="/gotwebd_test_harness/got.png" /></a></div></header><nav id="site_path"><div id="site_link"><a href="?index_page=0">Repos</a> / <a href="?action=summary&path=repo.git">repo.git</a> / <a href="?action=blame&commit=${COMMIT_ID}&path=repo.git">blame</a> / alpha</div></nav><main class="action-blame"><header class="subtitle"><h2>Blame</h2></header><div id="blame_content"><div class="page_header_wrapper"><dl><dt>Date:</dt><dd><time datetime="${COMMIT_YMDHMS}">${COMMIT_DATE}
+ UTC</time></dd><dt>Message:</dt><dd class="commit-msg">import the test tree
+</dd><dt>Actions:</dt><dd><a href="?action=briefs&commit=${COMMIT_ID}&file=alpha&folder=&path=repo.git">History</a> | <a href="?action=blob&commit=${COMMIT_ID}&file=alpha&folder=&path=repo.git">Blob</a> | <a href="?action=blobraw&commit=${COMMIT_ID}&file=alpha&folder=&path=repo.git">Raw File</a></dd></dl></div><hr /><pre id="blame"><div class="blame_line"><span class="blame_number">1 </span><span class="blame_hash"><a href="?action=diff&commit=${COMMIT_ID}&path=repo.git">${COMMIT_ID8}</a></span> <span class="blame_date">${COMMIT_YMD}</span> <span class="blame_author">${COMMITTER}</span> <span class="blame_code">alpha
+</span></div></pre></div></main><footer id="site_owner_wrapper"><p id="site_owner">Got Owner</p></footer></body></html>
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
+
+<!doctype html><html><head><meta charset="utf-8" /><title>Gotweb</title><meta name="viewport" content="initial-scale=1.0" /><meta name="msapplication-TileColor" content="#da532c" /><meta name="theme-color" content="#ffffff"/><link rel="apple-touch-icon" sizes="180x180" href="/gotwebd_test_harness/apple-touch-icon.png" /><link rel="icon" type="image/png" sizes="32x32" href="/gotwebd_test_harness/favicon-32x32.png" /><link rel="icon" type="image/png" sizes="16x16" href="/gotwebd_test_harness/favicon-16x16.png" /><link rel="manifest" href="/gotwebd_test_harness/site.webmanifest"/><link rel="mask-icon" href="/gotwebd_test_harness/safari-pinned-tab.svg" /><link rel="stylesheet" type="text/css" href="/gotwebd_test_harness/gotweb.css" /></head><body><header id="header"><div id="got_link"><a href="https://gameoftrees.org" target="_blank"><img src="/gotwebd_test_harness/got.png" /></a></div></header><nav id="site_path"><div id="site_link"><a href="?index_page=0">Repos</a> / <a href="?action=summary&path=repo.git">repo.git</a> / <a href="?action=tree&path=repo.git">tree</a> / </div></nav><main class="action-tree"><header class='subtitle'><h2>Tree</h2></header><div id="tree_content"><div class="page_header_wrapper"><dl><dt>Tree:</dt><dd><code class="commit-id">${TREE_ID}</code></dd><dt>Date:</dt><dd><time datetime="${COMMIT_YMDHMS}">${COMMIT_DATE}
+ UTC</time></dd><dt>Message:</dt><dd class="commit-msg">import the test tree
+</dd></dl></div><hr /><table id="tree"><tr class="tree_wrapper"><td class="tree_line"><a href="?action=blob&commit=${COMMIT_ID}&file=alpha&folder=&path=repo.git">alpha</a></td><td class="tree_line_blank"><a href="?action=commits&commit=${COMMIT_ID}&file=alpha&folder=&path=repo.git">commits</a> | <a href="?action=blame&commit=${COMMIT_ID}&file=alpha&folder=&path=repo.git">blame</a></td></tr><tr class="tree_wrapper"><td class="tree_line"><a href="?action=blob&commit=${COMMIT_ID}&file=beta&folder=&path=repo.git">beta</a></td><td class="tree_line_blank"><a href="?action=commits&commit=${COMMIT_ID}&file=beta&folder=&path=repo.git">commits</a> | <a href="?action=blame&commit=${COMMIT_ID}&file=beta&folder=&path=repo.git">blame</a></td></tr><tr class="tree_wrapper"><td class="tree_line" colspan=2><a href="?action=tree&commit=${COMMIT_ID}&folder=%2Fepsilon&path=repo.git">epsilon/</a></td></tr><tr class="tree_wrapper"><td class="tree_line" colspan=2><a href="?action=tree&commit=${COMMIT_ID}&folder=%2Fgamma&path=repo.git">gamma/</a></td></tr></table></div></main><footer id="site_owner_wrapper"><p id="site_owner">Got Owner</p></footer></body></html>
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 <https://bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68