]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/tag.t
3383fd475c25d25d73376e56061d8c713d8cfc7f
[git.ikiwiki.info.git] / t / tag.t
1 #!/usr/bin/perl
2 package IkiWiki;
4 use warnings;
5 use strict;
6 use Test::More tests => 10;
8 BEGIN { use_ok("IkiWiki"); }
9 BEGIN { use_ok("IkiWiki::Plugin::tag"); }
11 ok(! system("rm -rf t/tmp; mkdir t/tmp"));
13 $config{userdir} = "users";
14 $config{tagbase} = "tags";
15 $config{tagged_is_strict} = 1;
17 %oldrenderedfiles=%pagectime=();
18 %pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks=
19 %destsources=%renderedfiles=%pagecase=%pagestate=();
21 foreach my $page (qw(tags/numbers tags/letters one two alpha beta)) {
22         $pagesources{$page} = "$page.mdwn";
23         $pagemtime{$page} = $pagectime{$page} = 1000000;
24 }
26 $links{one}=[qw(tags/numbers alpha tags/letters)];
27 $links{two}=[qw(tags/numbers)];
28 $links{alpha}=[qw(tags/letters one)];
29 $links{beta}=[qw(tags/letters)];
30 $typedlinks{one}={tag => {"tags/numbers" => 1 }};
31 $typedlinks{two}={tag => {"tags/numbers" => 1 }};
32 $typedlinks{alpha}={tag => {"tags/letters" => 1 }};
33 $typedlinks{beta}={tag => {"tags/letters" => 1 }};
35 ok(pagespec_match("one", "tagged(numbers)"));
36 ok(!pagespec_match("two", "tagged(alpha)"));
37 ok(pagespec_match("one", "link(tags/numbers)"));
38 ok(pagespec_match("one", "link(alpha)"));
40 ok(pagespec_match("one", "typedlink(tag tags/numbers)"));
41 ok(!pagespec_match("one", "typedlink(tag tags/letters)"));
42 # invalid syntax
43 ok(pagespec_match("one", "typedlink(tag)")->isa("IkiWiki::ErrorReason"));
45 1;