]> sipb.mit.edu Git - ikiwiki.git/blob - t/comments.t
fix for thumbnail size bug
[ikiwiki.git] / t / comments.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Test::More 'no_plan';
5 use IkiWiki;
6
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");
11
12 my $comment;
13
14 $comment = <<EOF;
15 [[!comment username="neil"
16   date="1969-07-20T20:17:40Z"
17   content="I landed"]]
18 EOF
19 #ok(eval { writefile("post/comment_3._comment", "t/tmp/in", $comment); 1 });
20 writefile("post/comment_3._comment", "t/tmp/in", $comment);
21
22 $comment = <<EOF;
23 [[!comment username="christopher"
24   date="1969-02-12T07:00:00Z"
25   content="I explored"]]
26 EOF
27 writefile("post/comment_2._comment", "t/tmp/in", $comment);
28
29 $comment = <<EOF;
30 [[!comment username="william"
31   date="1969-01-14T12:00:00Z"
32   content="I conquered"]]
33 EOF
34 writefile("post/comment_1._comment", "t/tmp/in", $comment);
35
36 # Give the files mtimes in the wrong order
37 ok(utime(111111111, 111111111, "t/tmp/in/post/comment_3._comment"));
38 ok(utime(222222222, 222222222, "t/tmp/in/post/comment_2._comment"));
39 ok(utime(333333333, 333333333, "t/tmp/in/post/comment_1._comment"));
40
41 # Build the wiki
42 ok(! system("make -s ikiwiki.out"));
43 ok(! system("perl -I. ./ikiwiki.out -verbose -plugin comments -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -set comments_pagespec='*' -templatedir=templates t/tmp/in t/tmp/out"));
44
45 # Check that the comments are in the right order
46
47 sub slurp {
48     open my $fh, "<", shift or return undef;
49     local $/;
50     my $content = <$fh>;
51     close $fh or return undef;
52     return $content;
53 }
54
55 my $content = slurp("t/tmp/out/post/index.html");
56 ok(defined $content);
57 ok($content =~ m/I conquered.*I explored.*I landed/s);