]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/comments.t
Revert vandalism
[git.ikiwiki.info.git] / t / comments.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Test::More;
5 use IkiWiki;
7 ok(! system("rm -rf t/tmp"));
8 ok(mkdir "t/tmp");
9 ok(! system("cp -R t/tinyblog t/tmp/in"));
10 ok(mkdir "t/tmp/in/post" or -d "t/tmp/in/post");
12 my $installed = $ENV{INSTALLED_TESTS};
14 my @command;
15 if ($installed) {
16         @command = qw(ikiwiki);
17 }
18 else {
19         ok(! system("make -s ikiwiki.out"));
20         @command = qw(perl -I. ./ikiwiki.out
21                 --underlaydir=underlays/basewiki
22                 --set underlaydirbase=underlays
23                 --templatedir=templates);
24 }
26 my $comment;
28 $comment = <<EOF;
29 [[!comment username="neil"
30   date="1969-07-20T20:17:40Z"
31   content="I landed"]]
32 EOF
33 #ok(eval { writefile("post/comment_3._comment", "t/tmp/in", $comment); 1 });
34 writefile("post/comment_3._comment", "t/tmp/in", $comment);
36 $comment = <<EOF;
37 [[!comment username="christopher"
38   date="1969-02-12T07:00:00Z"
39   content="I explored"]]
40 EOF
41 writefile("post/comment_2._comment", "t/tmp/in", $comment);
43 $comment = <<EOF;
44 [[!comment username="william"
45   date="1969-01-14T12:00:00Z"
46   content="I conquered"]]
47 EOF
48 writefile("post/comment_1._comment", "t/tmp/in", $comment);
50 # Give the files mtimes in the wrong order
51 ok(utime(111111111, 111111111, "t/tmp/in/post/comment_3._comment"));
52 ok(utime(222222222, 222222222, "t/tmp/in/post/comment_2._comment"));
53 ok(utime(333333333, 333333333, "t/tmp/in/post/comment_1._comment"));
55 # Build the wiki
56 ok(! system(@command, qw(--verbose --plugin comments --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi --rss --atom --set comments_pagespec=* t/tmp/in t/tmp/out)));
58 # Check that the comments are in the right order
60 sub slurp {
61     open my $fh, "<", shift or return undef;
62     local $/;
63     my $content = <$fh>;
64     close $fh or return undef;
65     return $content;
66 }
68 my $content = slurp("t/tmp/out/post/index.html");
69 ok(defined $content);
70 ok($content =~ m/I conquered.*I explored.*I landed/s);
72 done_testing();