htmltidy: Avoid breaking the sidebar when websetup is running.
[ikiwiki.git] / t / autoindex.t
blob9bef2415a23ea597ec29434845a2271c47f0d053
1 #!/usr/bin/perl
2 package IkiWiki;
4 use warnings;
5 use strict;
6 use Test::More tests => 17;
8 BEGIN { use_ok("IkiWiki"); }
9 BEGIN { use_ok("IkiWiki::Render"); }
10 BEGIN { use_ok("IkiWiki::Plugin::autoindex"); }
11 BEGIN { use_ok("IkiWiki::Plugin::html"); }
12 BEGIN { use_ok("IkiWiki::Plugin::mdwn"); }
14 ok(! system("rm -rf t/tmp; mkdir t/tmp"));
16 $config{verbose} = 1;
17 $config{srcdir} = 't/tmp';
18 $config{underlaydir} = 't/tmp';
19 $config{underlaydirbase} = '.';
20 $config{templatedir} = 'templates';
21 $config{usedirs} = 1;
22 $config{htmlext} = 'html';
23 $config{wiki_file_chars} = "-[:alnum:]+/.:_";
24 $config{userdir} = "users";
25 $config{tagbase} = "tags";
26 $config{default_pageext} = "mdwn";
27 $config{wiki_file_prune_regexps} = [qr/^\./];
29 is(checkconfig(), 1);
31 %oldrenderedfiles=%pagectime=();
32 %pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks=
33 %destsources=%renderedfiles=%pagecase=%pagestate=();
35 # pages that (we claim) were deleted in an earlier pass
36 $wikistate{autoindex}{deleted}{deleted} = 1;
37 $wikistate{autoindex}{deleted}{expunged} = 1;
38 $wikistate{autoindex}{deleted}{reinstated} = 1;
40 foreach my $page (qw(tags/numbers deleted/bar reinstated reinstated/foo gone/bar)) {
41 # we use a non-default extension for these, so they're distinguishable
42 # from programmatically-created pages
43 $pagesources{$page} = "$page.html";
44 $pagemtime{$page} = $pagectime{$page} = 1000000;
45 writefile("$page.html", "t/tmp", "your ad here");
48 # "gone" disappeared just before this refresh pass so it still has a mtime
49 $pagemtime{gone} = $pagectime{gone} = 1000000;
51 IkiWiki::Plugin::autoindex::refresh();
53 # these pages are still on record as having been deleted, because they have
54 # a reason to be re-created
55 is($wikistate{autoindex}{deleted}{deleted}, 1);
56 is($wikistate{autoindex}{deleted}{gone}, 1);
57 ok(! -f "t/tmp/deleted.mdwn");
58 ok(! -f "t/tmp/gone.mdwn");
60 # this page does not exist and has no reason to be re-created, so we forget
61 # about it - it will be re-created if it gains sub-pages
62 ok(! exists $wikistate{autoindex}{deleted}{expunged});
63 ok(! -f "t/tmp/expunged.mdwn");
65 # this page was re-created, so it drops off the radar
66 ok(! exists $wikistate{autoindex}{deleted}{reinstated});
67 ok(! -f "t/tmp/reinstated.mdwn");
69 # needs creating
70 ok(! exists $wikistate{autoindex}{deleted}{tags});
71 ok(-s "t/tmp/tags.mdwn");