#!/bin/sh
# The tree page browses a repository at one revision, either as a listing of a
# directory or as a single file with an anchor on every line. The checks
# against the repository named foo+bar cover a file name and a branch name
# that both contain a plus, which cgit percent-encodes in a path as well as in
# a query, since a bare plus in a served path would read back as a space when
# the link is requested through a query string.
test_description='Check content on tree page'
. ./setup.sh
test_expect_success 'generate bar/tree' 'cgit_url "bar/tree" >tmp'
test_expect_success 'find file-1' 'grep "file-1" tmp'
test_expect_success 'find file-50' 'grep "file-50" tmp'
test_expect_success 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >tmp'
test_expect_success 'find line 1' '
grep "1" tmp
'
test_expect_success 'no line 2' '
! grep "2" tmp
'
test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >tmp'
test_expect_success 'verify a+b link' '
grep "/foo%2Bbar/tree/a%2Bb" tmp
'
test_expect_success 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&h=1%2b2" >tmp'
test_expect_success 'verify a+b?h=1+2 link' '
grep "/foo%2Bbar/tree/a%2Bb?h=1%2B2" tmp
'
test_done