Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Add the shared config writers and cgit_rc
The helpers are named by kind. cgitrc_repo and cgitrc_copy write the
config file named first, and cgit_url, cgit_query and cgit_rc run cgit,
each named after what it is handed first. A repository copies its
defaults from the globals read before its repo.url, so cgitrc_repo
places every setting itself, and a global can no longer land where it
silently stops applying. The t00xx and t01xx files move to them here.
Diffstat (limited to '')
| -rwxr-xr-x | tests/t0112-stats.sh | 50 |
1 file changed, 15 insertions, 35 deletions
diff --git a/tests/t0112-stats.sh b/tests/t0112-stats.sh index 3728412..5100793 100755 --- a/tests/t0112-stats.sh +++ b/tests/t0112-stats.sh @@ -28,31 +28,17 @@ test_expect_success 'set up a stats config' ' git commit --allow-empty -m fresh && git commit-graph write --reachable ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "max-stats=year" && - echo "repo.url=stat" && - echo "repo.path=$PWD/repos/pulse/.git" - } >statsrc && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "max-stats=month" && - echo "repo.url=stat" && - echo "repo.path=$PWD/repos/pulse/.git" - } >statmaxrc + cgitrc_repo statsrc stat max-stats=year "repo.path=$PWD/repos/pulse/.git" && + cgitrc_repo statmaxrc stat max-stats=month "repo.path=$PWD/repos/pulse/.git" ' -statq() { CGIT_CONFIG="$PWD/statsrc" QUERY_STRING="$1" cgit; } - test_expect_success 'stats tab appears when enabled' ' - statq "url=stat/" >tmp && + cgit_rc statsrc "url=stat/" >tmp && grep ">stats</a>" tmp ' test_expect_success 'stats page renders the authors table' ' - statq "url=stat/stats/" >tmp && + cgit_rc statsrc "url=stat/stats/" >tmp && grep "<h2>Commits per author" tmp ' @@ -65,13 +51,13 @@ test_expect_success 'stat options sit above the content' ' ' test_expect_success 'stats below a path stay a normal page' ' - statq "url=stat/stats/file-1" >tmp && + cgit_rc statsrc "url=stat/stats/file-1" >tmp && grep "Status: 200" tmp && grep "<h2>Commits per author" tmp ' test_expect_success 'max-stats=year offers all four periods' ' - statq "url=stat/stats/" >tmp && + cgit_rc statsrc "url=stat/stats/" >tmp && grep "<option value=.w." tmp && grep "<option value=.m." tmp && grep "<option value=.q." tmp && @@ -79,20 +65,20 @@ test_expect_success 'max-stats=year offers all four periods' ' ' test_expect_success 'max-stats bounds the selectable periods' ' - CGIT_CONFIG="$PWD/statmaxrc" QUERY_STRING="url=stat/stats/&period=y" cgit >tmp && + cgit_rc statmaxrc "url=stat/stats/&period=y" >tmp && grep "Statistics type disabled" tmp && - CGIT_CONFIG="$PWD/statmaxrc" QUERY_STRING="url=stat/stats/" cgit >tmp && + cgit_rc statmaxrc "url=stat/stats/" >tmp && ! grep "<option value=.q." tmp ' # Each period buckets commits and labels its columns its own way, so every one # gets a page of its own here. test_expect_success 'every period renders its own columns' ' - statq "url=stat/stats/&period=m" >tmp && + cgit_rc statsrc "url=stat/stats/&period=m" >tmp && grep -E "<th[^>]*>[A-Z][a-z][a-z] [0-9]{4}</th>" tmp && - statq "url=stat/stats/&period=q" >tmp && + cgit_rc statsrc "url=stat/stats/&period=q" >tmp && grep -E "<th[^>]*>Q[1-4] [0-9]{4}</th>" tmp && - statq "url=stat/stats/&period=y" >tmp && + cgit_rc statsrc "url=stat/stats/&period=y" >tmp && grep -E "<th[^>]*>[0-9]{4}</th>" tmp ' @@ -112,14 +98,8 @@ test_expect_success 'the window opens at midnight on its first day' ' GIT_COMMITTER_DATE="$first-01-01 00:00:00 +0000" \ git commit --allow-empty -m first ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "max-stats=year" && - echo "repo.url=edge" && - echo "repo.path=$PWD/repos/edge/.git" - } >edgerc && - CGIT_CONFIG="$PWD/edgerc" QUERY_STRING="url=edge/stats/&period=y" cgit >tmp && + cgitrc_repo edgerc edge max-stats=year && + cgit_rc edgerc "url=edge/stats/&period=y" >tmp && grep ">Early Bird<" tmp && ! grep ">Too Early<" tmp ' @@ -127,9 +107,9 @@ test_expect_success 'the window opens at midnight on its first day' ' # A path starting with a colon would reach git as pathspec magic, which the # log, the feed and the patch page refuse as well. test_expect_success 'a path with pathspec magic is refused' ' - statq "url=stat/stats/%3A%28icase%29FILE-1" >tmp && + cgit_rc statsrc "url=stat/stats/%3A%28icase%29FILE-1" >tmp && grep "^Status: 400" tmp && - statq "url=stat/stats/file-1" >tmp && + cgit_rc statsrc "url=stat/stats/file-1" >tmp && grep "^Status: 200" tmp ' |
