Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[ikiwiki] / t / tag.t
1 #!/usr/bin/perl
2 package IkiWiki;
3
4 use warnings;
5 use strict;
6 use Test::More tests => 7;
7
8 BEGIN { use_ok("IkiWiki"); }
9 BEGIN { use_ok("IkiWiki::Plugin::tag"); }
10
11 ok(! system("rm -rf t/tmp; mkdir t/tmp"));
12
13 $config{userdir} = "users";
14 $config{tagbase} = "tags";
15
16 %oldrenderedfiles=%pagectime=();
17 %pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks=
18 %destsources=%renderedfiles=%pagecase=%pagestate=();
19
20 foreach my $page (qw(tags/numbers tags/letters one two alpha beta)) {
21         $pagesources{$page} = "$page.mdwn";
22         $pagemtime{$page} = $pagectime{$page} = 1000000;
23 }
24
25 $links{one}=[qw(tags/numbers alpha tags/letters)];
26 $links{two}=[qw(tags/numbers)];
27 $links{alpha}=[qw(tags/letters one)];
28 $links{beta}=[qw(tags/letters)];
29 $typedlinks{one}={tag => {"tags/numbers" => 1 }};
30 $typedlinks{two}={tag => {"tags/numbers" => 1 }};
31 $typedlinks{alpha}={tag => {"tags/letters" => 1 }};
32 $typedlinks{beta}={tag => {"tags/letters" => 1 }};
33
34 ok(pagespec_match("one", "tagged(numbers)"));
35 ok(!pagespec_match("two", "tagged(alpha)"));
36 ok(pagespec_match("one", "link(tags/numbers)"));
37 ok(pagespec_match("one", "link(alpha)"));
38
39 1;