diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t0201-limits.sh45
1 file changed, 42 insertions, 3 deletions
diff --git a/tests/t0201-limits.sh b/tests/t0201-limits.sh
index e7f74c6..b7d82de 100755
--- a/tests/t0201-limits.sh
+++ b/tests/t0201-limits.sh
@@ -1,9 +1,10 @@
#!/bin/sh
-test_description='Check the ref listing limits'
+test_description='Check the ref listing and diff size limits'
. ./setup.sh
-# A repo with several branches and tags, and a config that pins a tiny limit.
+# A repo with several branches and tags, one commit with an oversized file
+# diff beside a small one, and configs that pin tiny limits.
test_expect_success 'set up limit fixtures' '
mkrepo repos/limits 1 &&
(
@@ -22,9 +23,18 @@ test_expect_success 'set up limit fixtures' '
echo "virtual-root=/" &&
echo "cache-size=0" &&
echo "max-ref-count=2" &&
+ echo "max-diff-lines=20" &&
+ echo "max-diff-files=0" &&
echo "repo.url=limits" &&
echo "repo.path=$PWD/repos/limits/.git"
- } >limitrc
+ } >limitrc &&
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "max-diff-files=1" &&
+ echo "repo.url=limits" &&
+ echo "repo.path=$PWD/repos/limits/.git"
+ } >limitfilesrc
'
limitq() { CGIT_CONFIG="$PWD/limitrc" QUERY_STRING="$1" cgit; }
@@ -57,4 +67,33 @@ test_expect_success 'tag page paginates independently' '
! grep "log/?h=" tmp
'
+# --- Oversized file diffs link out instead of rendering inline --------------
+test_expect_success 'oversized file diff is replaced by a link' '
+ limitq "url=limits/commit/" >tmp &&
+ grep "too large to be rendered inline" tmp &&
+ grep "View it on its own page" tmp
+'
+
+test_expect_success 'small file in the same commit still renders inline' '
+ grep "class=.add.>+int y;" tmp
+'
+
+test_expect_success 'the single-file diff page always renders in full' '
+ limitq "url=limits/diff/big.c" >tmp &&
+ grep "class=.hunk." tmp &&
+ ! grep "too large to be rendered inline" tmp
+'
+
+# --- Commits over max-diff-files fall back to the diffstat ------------------
+test_expect_success 'a commit changing too many files shows stat only' '
+ CGIT_CONFIG="$PWD/limitfilesrc" QUERY_STRING="url=limits/commit/" cgit >tmp &&
+ grep "too large to be rendered inline" tmp &&
+ ! grep "class=.hunk." tmp
+'
+
+test_expect_success 'the single-file page is not limited by max-diff-files' '
+ CGIT_CONFIG="$PWD/limitfilesrc" QUERY_STRING="url=limits/diff/small.c" cgit >tmp &&
+ grep "class=.hunk." tmp
+'
+
test_done