]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/tag.t
Merge remote branch 'smcv/ready/sort-package'
[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";
16 %oldrenderedfiles=%pagectime=();
17 %pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks=
18 %destsources=%renderedfiles=%pagecase=%pagestate=();
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 }
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 }};
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)"));
39 ok(pagespec_match("one", "typedlink(tag tags/numbers)"));
40 ok(!pagespec_match("one", "typedlink(tag tags/letters)"));
41 # invalid syntax
42 ok(pagespec_match("one", "typedlink(tag)")->isa("IkiWiki::ErrorReason"));
44 1;