]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - t/comments.t
libtext-csv-xs-perl not relevant
[git.ikiwiki.info.git] / t / comments.t
index a5add970192c953b77c9968ebd0a51cbb4f46755..fc87d72ff273f3d83d800f62ee637287efa20357 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
+use Cwd qw(getcwd);
 use Test::More;
 use IkiWiki;
 
@@ -17,10 +18,10 @@ if ($installed) {
 }
 else {
        ok(! system("make -s ikiwiki.out"));
-       @command = qw(perl -I. ./ikiwiki.out
+       @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
                --underlaydir=underlays/basewiki
                --set underlaydirbase=underlays
-               --templatedir=templates);
+               --templatedir=templates));
 }
 
 my $comment;
@@ -38,7 +39,7 @@ $comment = <<EOF;
   date="1969-02-12T07:00:00Z"
   content="I explored"]]
 EOF
-writefile("post/comment_2._comment", "t/tmp/in", $comment);
+writefile("post/comment_2_10a49d69282155c5c3e66dc58f64f956._comment", "t/tmp/in", $comment);
 
 $comment = <<EOF;
 [[!comment username="william"
@@ -49,7 +50,7 @@ writefile("post/comment_1._comment", "t/tmp/in", $comment);
 
 # Give the files mtimes in the wrong order
 ok(utime(111111111, 111111111, "t/tmp/in/post/comment_3._comment"));
-ok(utime(222222222, 222222222, "t/tmp/in/post/comment_2._comment"));
+ok(utime(222222222, 222222222, "t/tmp/in/post/comment_2_10a49d69282155c5c3e66dc58f64f956._comment"));
 ok(utime(333333333, 333333333, "t/tmp/in/post/comment_1._comment"));
 
 # Build the wiki
@@ -67,6 +68,18 @@ sub slurp {
 
 my $content = slurp("t/tmp/out/post/index.html");
 ok(defined $content);
-ok($content =~ m/I conquered.*I explored.*I landed/s);
+like($content, qr/I conquered.*I explored.*I landed/s);
+
+$content = slurp("t/tmp/out/post/index.atom");
+ok(defined $content);
+like($content, qr{
+       <link\s*href="http://example\.com/post/[#]comment-[[:xdigit:]]+"
+       .*
+       <link\s*href="http://example\.com/post/[#]comment-[[:xdigit:]]+"
+       .*
+       <link\s*href="http://example\.com/post/[#]comment-[[:xdigit:]]+"
+}sx, 'Each comment gets an appropriate permalink in <link>');
+unlike($content, qr{<link\s*href=.*/post/comment_[123]/});
+unlike($content, qr{<link\s*href=.*/post/comment_[123]_[[:xdigit:]]+/});
 
 done_testing();