Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Move the later tests to the config writers
The one-line request wrappers go with them. Configs with several repositories, a key out of place on purpose, the cache on or no repository of their own stay written out.
Diffstat (limited to 'tests/t0201-filters.sh')
-rwxr-xr-xtests/t0201-filters.sh31
1 file changed, 11 insertions, 20 deletions
diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh
index 2e59a1d..8d8743a 100755
--- a/tests/t0201-filters.sh
+++ b/tests/t0201-filters.sh
@@ -57,9 +57,8 @@ do
done
test_expect_success 'the blame page goes through the source filter too' '
- echo "enable-blame=1" >blamerc &&
- sed "s/^cache-size=.*/cache-size=0/" cgitrc >>blamerc &&
- CGIT_CONFIG="$PWD/blamerc" QUERY_STRING="url=filter-exec/blame/a%2bb" cgit >tmp &&
+ cgitrc_copy blamerc enable-blame=1 &&
+ cgit_rc blamerc "url=filter-exec/blame/a%2bb" >tmp &&
grep "<td class=.linenumbers.>" tmp &&
grep "<code>a+b HELLO$" tmp
'
@@ -67,22 +66,14 @@ test_expect_success 'the blame page goes through the source filter too' '
# A readme read at another branch links into the tree at that branch, which
# the filter is told as the query to follow a path with.
test_expect_success 'the about filter gets the tree url at the readme branch' '
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "readme=:a+b" &&
- echo "about-filter=exec:$FILTER_DIRECTORY/dump.sh" &&
- echo "root-readme=$PWD/root.txt" &&
- echo "repo.url=filtered" &&
- echo "repo.path=$PWD/repos/filter/.git"
- } >aboutargsrc &&
- CGIT_CONFIG="$PWD/aboutargsrc" QUERY_STRING="url=filtered/about/&h=1%2b2" cgit >tmp &&
+ cgitrc_repo aboutargsrc filtered readme=:a+b "about-filter=exec:$FILTER_DIRECTORY/dump.sh" "root-readme=$PWD/root.txt" "repo.path=$PWD/repos/filter/.git" &&
+ cgit_rc aboutargsrc "url=filtered/about/&h=1%2b2" >tmp &&
grep "<div id=.about.>a+b /filtered/tree/ ?h=1%2B2 HELLO" tmp
'
test_expect_success 'the site readme leaves the tree url empty' '
echo site >root.txt &&
- CGIT_CONFIG="$PWD/aboutargsrc" QUERY_STRING="p=about" cgit >tmp &&
+ cgit_rc aboutargsrc "p=about" >tmp &&
grep "root.txt SITE" tmp
'
@@ -92,9 +83,9 @@ test_expect_success 'only a repository page hands filters its variables' '
echo "repo url: $CGIT_REPO_URL."
EOF
sed "s|^about-filter=.*|about-filter=exec:$PWD/env.sh|" aboutargsrc >envrc &&
- CGIT_CONFIG="$PWD/envrc" QUERY_STRING="url=filtered/about/" cgit >tmp &&
+ cgit_rc envrc "url=filtered/about/" >tmp &&
grep "repo url: filtered\." tmp &&
- CGIT_CONFIG="$PWD/envrc" QUERY_STRING="p=about" cgit >tmp &&
+ cgit_rc envrc "p=about" >tmp &&
grep "repo url: \." tmp
'
@@ -113,7 +104,7 @@ test_expect_success CGIT_LUA 'a failing lua filter still renders an error page'
echo "repo.path=$PWD/repos/foo/.git" &&
echo "auth-filter=lua:$PWD/broken.lua"
} >brokenrc &&
- CGIT_CONFIG="$PWD/brokenrc" QUERY_STRING="url=foo/commit" cgit >tmp 2>err &&
+ cgit_rc brokenrc "url=foo/commit" >tmp 2>err &&
grep "Status: 500" tmp &&
grep "Lua error in" err
'
@@ -126,7 +117,7 @@ test_expect_success CGIT_LUA 'a lua filter raising a table is named by type' '
function filter_close() return 0 end
EOF
sed "s|broken.lua|tabled.lua|" brokenrc >tabledrc &&
- CGIT_CONFIG="$PWD/tabledrc" QUERY_STRING="url=foo/commit" cgit >tmp 2>err &&
+ cgit_rc tabledrc "url=foo/commit" >tmp 2>err &&
grep "Status: 500" tmp &&
grep "Lua error in .*tabled.lua: (error object is a table value)" err
'
@@ -146,7 +137,7 @@ test_expect_success CGIT_LUA 'a lua filter that writes while loading still rende
echo "repo.path=$PWD/repos/foo/.git" &&
echo "repo.commit-filter=lua:$PWD/loud.lua"
} >loudrc &&
- CGIT_CONFIG="$PWD/loudrc" QUERY_STRING="url=foo/commit" cgit >tmp &&
+ cgit_rc loudrc "url=foo/commit" >tmp &&
grep "written while loading" tmp &&
grep "</html>" tmp
'
@@ -173,7 +164,7 @@ test_expect_success CGIT_LUA 'a lua filter can encode an argument and include a
function filter_close() return 0 end
EOF
sed "s|loud.lua|apis.lua|" loudrc >apisrc &&
- CGIT_CONFIG="$PWD/apisrc" QUERY_STRING="url=foo/commit" cgit >tmp &&
+ cgit_rc apisrc "url=foo/commit" >tmp &&
grep "a+b%26c|included <b>bold</b>" tmp
'