blob: 5ce1fabc11c53c0e1bcc6cb8bc2effd8500a2170 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh

# The summary page is the landing page for a single repository, holding its
# most recent commits together with its branches and its tags. The shared
# setup caps that log at five entries, so the checks against the fifty commit
# repository are really checking that the cut lands where it should. They also
# confirm the clone url template from cgitrc has had the repository name
# substituted into it.

test_description='Check content on summary page'
. ./setup.sh

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 'no tags' '! grep "Tag</th>" tmp'
test_expect_success 'clone-url expanded correctly' '
	grep "git://example.org/foo.git" tmp
'

test_expect_success 'generate bar summary' 'cgit_url "bar" >tmp'
test_expect_success 'repo description reaches the meta tag' '
	grep "<meta name=.description. content=.the bar repo.>" tmp
'
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
# the repository's own page when the list has none.
test_expect_success 'a git clone url row falls back to the page url' '
	grep "clone-url.><a rel=.vcs-git. title=.bar Git repository. href=./bar/.>git://example.org/bar.git</a>" tmp
'

test_expect_success 'an scp clone url row links to the http url' '
	{
		echo "virtual-root=/" &&
		echo "cache-size=0" &&
		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
'

test_done