]> sipb.mit.edu Git - ikiwiki.git/blob - t/tag.t
implement typed links; add tagged_is_strict config option
[ikiwiki.git] / t / tag.t
1 #!/usr/bin/perl
2 package IkiWiki;
3
4 use warnings;
5 use strict;
6 use Test::More tests => 10;
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 $config{tagged_is_strict} = 1;
16
17 %oldrenderedfiles=%pagectime=();
18 %pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks=
19 %destsources=%renderedfiles=%pagecase=%pagestate=();
20
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 }
25
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 }};
34
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)"));
39
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"));
44
45 1;