Diff options
Diffstat (limited to '')
-rwxr-xr-xtests/t0102-summary.sh48
1 file changed, 33 insertions, 15 deletions
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh
index e95f270..9e0e14c 100755
--- a/tests/t0102-summary.sh
+++ b/tests/t0102-summary.sh
@@ -11,7 +11,7 @@ test_description='Check content on summary page'
test_expect_success 'generate foo summary' 'cgit_url "foo" >tmp'
test_expect_success 'find commit 1' 'grep "commit 1" tmp'
test_expect_success 'find commit 5' 'grep "commit 5" tmp'
-test_expect_success 'find branch master' 'grep "master" tmp'
+test_expect_success 'find branch master' 'grep "<tr class=.branch.><td><a[^>]*>master</a>" tmp'
test_expect_success 'no tags' '! grep "Tag</th>" tmp'
test_expect_success 'clone-url expanded correctly' '
grep "git://example.org/foo.git" tmp
@@ -24,11 +24,6 @@ test_expect_success 'repo description reaches the meta tag' '
test_expect_success 'no commit 45' '! grep "commit 45" tmp'
test_expect_success 'find commit 46' 'grep "commit 46" tmp'
test_expect_success 'find commit 50' 'grep "commit 50" tmp'
-test_expect_success 'find branch master' 'grep "master" tmp'
-test_expect_success 'no tags' '! grep "Tag</th>" tmp'
-test_expect_success 'clone-url expanded correctly' '
- grep "git://example.org/bar.git" tmp
-'
# A clone url is shown as written, but a browser cannot follow the ssh, scp
# or git forms, so those rows link to the first http url in the list, or to
@@ -38,17 +33,40 @@ test_expect_success 'a git clone url row falls back to the page url' '
'
test_expect_success 'an scp clone url row links to the http url' '
+ cgitrc_repo clonerc foo "repo.clone-url=git@example.org:foo https://example.org/foo" &&
+ cgit_rc clonerc "url=foo" >tmp &&
+ grep "title=.foo Git repository. href=.https://example.org/foo.>git@example.org:foo</a>" tmp &&
+ grep "vcs-git. href=.https://example.org/foo." tmp &&
+ ! grep "vcs-git. href=.git@" tmp
+'
+
+# A repository can turn the global clone-url off with an empty one of its own.
+# Neither its summary nor the page an empty repository gets then draws a Clone
+# heading over no rows.
+test_expect_success 'an empty clone url draws no clone heading' '
+ git init -q --bare repos/empty.git &&
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
+ echo "clone-url=https://example.org/\$CGIT_REPO_URL" &&
echo "repo.url=foo" &&
echo "repo.path=$PWD/repos/foo/.git" &&
- echo "repo.clone-url=git@example.org:foo https://example.org/foo"
- } >clonerc &&
- CGIT_CONFIG="$PWD/clonerc" QUERY_STRING="url=foo" cgit >tmp &&
- grep "title=.foo Git repository. href=.https://example.org/foo.>git@example.org:foo</a>" tmp &&
- grep "vcs-git. href=.https://example.org/foo." tmp &&
- ! grep "vcs-git. href=.git@" tmp
+ echo "repo.clone-url=" &&
+ echo "repo.url=empty" &&
+ echo "repo.path=$PWD/repos/empty.git" &&
+ echo "repo.clone-url=" &&
+ echo "repo.url=cloned" &&
+ echo "repo.path=$PWD/repos/empty.git"
+ } >emptyrc &&
+ cgit_rc emptyrc "url=foo" >tmp &&
+ grep "commit 1" tmp &&
+ ! grep "Clone</th>" tmp &&
+ cgit_rc emptyrc "url=empty" >tmp &&
+ grep "Repository seems to be empty" tmp &&
+ ! grep "Clone</th>" tmp &&
+ cgit_rc emptyrc "url=cloned" >tmp &&
+ grep "Clone</th>" tmp &&
+ grep "https://example.org/cloned</a>" tmp
'
# Prints how many columns each row of the page's list table spans, one row to
@@ -74,7 +92,7 @@ row_widths() {
# Fails unless every row of the list table at the url is as many columns wide
# as the second argument says. A third names a config other than colsrc.
test_widths() {
- CGIT_CONFIG="$PWD/${3:-colsrc}" QUERY_STRING="url=$1" cgit >tmp &&
+ cgit_rc "${3:-colsrc}" "url=$1" >tmp &&
row_widths tmp | sort -u >actual &&
echo "$2" >expect &&
test_cmp expect actual
@@ -86,7 +104,7 @@ test_widths() {
# Each repo below shows the same history with different counts, and every
# section is cut short so that its [...] row is drawn too.
test_expect_success 'set up a repo cut short in every section' '
- mkrepo repos/cols 3 >/dev/null &&
+ mkrepo repos/cols 3 &&
git -C repos/cols branch other HEAD~1 &&
git -C repos/cols tag one HEAD~1 &&
git -C repos/cols tag -a -m two two &&
@@ -108,7 +126,7 @@ test_expect_success 'set up a repo cut short in every section' '
echo "repo.enable-log-filecount=1" &&
echo "repo.enable-log-linecount=1"
} >colsrc &&
- CGIT_CONFIG="$PWD/colsrc" QUERY_STRING="url=none" cgit >tmp &&
+ cgit_rc colsrc "url=none" >tmp &&
grep "<tbody class=.tags.>" tmp &&
grep "<tbody class=.clone.>" tmp &&
test $(grep -c ">\[...\]</a>" tmp) = 3