summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Mangano-Tarumi <fmang@mg0.fr>2020-01-31 03:20:26 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2020-02-02 12:12:43 +0100
commit0fc69e96bdd1197ca2b91bcd16a3064366954c06 (patch)
tree76132c9d22b30ff6fbcd5247198838c3aff9d0ab
parentc277a3de8f3255be31a2c3f08cd49fe2f6c36aa3 (diff)
downloadaur-0fc69e96bdd1197ca2b91bcd16a3064366954c06.tar.gz
aur-0fc69e96bdd1197ca2b91bcd16a3064366954c06.tar.xz
rendercomment: add a test for Git commit links
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rwxr-xr-xtest/t2600-rendercomment.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/t2600-rendercomment.sh b/test/t2600-rendercomment.sh
index edf290cd..7b3a4a8d 100755
--- a/test/t2600-rendercomment.sh
+++ b/test/t2600-rendercomment.sh
@@ -63,4 +63,33 @@ test_expect_success 'Test link conversion.' '
test_cmp actual expected
'
+test_expect_success 'Test Git commit linkification.' '
+ local oid=`git -C aur.git rev-parse --verify HEAD`
+ cat <<-EOD | sqlite3 aur.db &&
+ INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (5, 1, "
+ $oid
+ ${oid:0:7}
+ x.$oid.x
+ ${oid}x
+ 0123456789abcdef
+ \`$oid\`
+ http://example.com/$oid
+ ", "");
+ EOD
+ "$RENDERCOMMENT" 5 &&
+ cat <<-EOD >expected &&
+ <p><a href="https://aur.archlinux.org/cgit/aur.git/log/?h=foobar&amp;id=${oid:0:12}">${oid:0:12}</a>
+ <a href="https://aur.archlinux.org/cgit/aur.git/log/?h=foobar&amp;id=${oid:0:7}">${oid:0:7}</a>
+ x.<a href="https://aur.archlinux.org/cgit/aur.git/log/?h=foobar&amp;id=${oid:0:12}">${oid:0:12}</a>.x
+ ${oid}x
+ 0123456789abcdef
+ <code>$oid</code>
+ <a href="http://example.com/$oid">http://example.com/$oid</a></p>
+ EOD
+ cat <<-EOD | sqlite3 aur.db >actual &&
+ SELECT RenderedComment FROM PackageComments WHERE ID = 5;
+ EOD
+ test_cmp actual expected
+'
+
test_done