Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Check the order of every index sort column
Only the name sort had its order checked. For the other columns the
test looked for one repository on the page, and the shared fixture
could not show an order anyway, since no repository there has an
owner and their ref times tie. Nothing read an age file either,
though the idle column takes its date from one first.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0101-index.sh | 61 |
1 file changed, 51 insertions, 10 deletions
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index d269bdc..4a8bdb3 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh @@ -69,17 +69,58 @@ test_expect_success 'a url matching no repository says so' ' grep "<div class=.error.>No repositories found</div>" tmp ' -# The index sorts by a column only when asked, which nothing else exercises. -test_expect_success 'the index sorts by a column on request' ' - cgit_query "s=name" >tmp && - bar=$(grep -n ">bar</a>" tmp | head -1 | cut -d: -f1) && - foo=$(grep -n ">foo</a>" tmp | head -1 | cut -d: -f1) && - test "$bar" -lt "$foo" && - for s in desc owner idle +# Fails unless the index of orderrc, asked for with the query given first, +# lists the repositories in the order the rest name. +test_index_order() { + cgit_ok orderrc "$1" >tmp && + sed -n "s/.*class=.col-name toplevel-repo.><a href=.\/.\/.>\(.\)<\/a>.*/\1/p" tmp >order && + shift && + printf "%s\n" "$@" >expect && + test_cmp expect order +} + +# Each column sorts these three into an order of its own, and none of them +# is the cgitrc order an unsorted index keeps. The age files date them in +# the reverse of the order they are made in, so the ref times alone cannot +# put the idle sort right. +test_expect_success 'set up repositories each column sorts apart' ' + for name in b a c do - cgit_query "s=$s" >tmp && - grep ">foo</a>" tmp || return 1 - done + git init -q --bare "orders/$name.git" && + mkdir "orders/$name.git/info/web" || return 1 + done && + echo "2005-04-03 10:00:00 +0000" >orders/a.git/info/web/last-modified && + echo "2005-04-05 10:00:00 +0000" >orders/b.git/info/web/last-modified && + echo "2005-04-01 10:00:00 +0000" >orders/c.git/info/web/last-modified && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "repo.url=c" && + echo "repo.path=$PWD/orders/c.git" && + echo "repo.desc=first by description" && + echo "repo.owner=second owner" && + echo "repo.url=a" && + echo "repo.path=$PWD/orders/a.git" && + echo "repo.desc=third by description" && + echo "repo.owner=first owner" && + echo "repo.url=b" && + echo "repo.path=$PWD/orders/b.git" && + echo "repo.desc=second by description" && + echo "repo.owner=third owner" + } >orderrc && + test_index_order "url=" c a b +' + +test_expect_success 'the index sorts by each column on request' ' + test_index_order "s=name" a b c && + test_index_order "s=desc" c b a && + test_index_order "s=owner" a c b && + test_index_order "s=idle" b a c +' + +test_expect_success 'the idle column shows the date the age file holds' ' + cgit_ok orderrc "url=" >tmp && + test_grep "<td class=.col-idle.><time class=.age-years. datetime=.2005-04-05T10:00:00Z." tmp ' # Only the heading of the column the index is sorted by tells a screen reader |
