]> sipb.mit.edu Git - ikiwiki.git/blobdiff - t/index.t
de-emphasize contributions to Joey; ikiwiki has more developers than just me. Donatio...
[ikiwiki.git] / t / index.t
index 107dac9d0522e73d435738d692af1e7a17cfb358..3f4b7d9b19a39286ddac71d8024efed8248b9037 100755 (executable)
--- a/t/index.t
+++ b/t/index.t
@@ -4,7 +4,7 @@ use strict;
 use IkiWiki;
 
 package IkiWiki; # use internal variables
-use Test::More tests => 27;
+use Test::More tests => 31;
 
 $config{wikistatedir}="/tmp/ikiwiki-test.$$";
 system "rm -rf $config{wikistatedir}";
@@ -31,21 +31,20 @@ $renderedfiles{"bar"}=["bar.html", "bar.rss", "sparkline-foo.gif"];
 $renderedfiles{"bar.png"}=["bar.png"];
 $links{"Foo"}=["bar.png"];
 $links{"bar"}=["Foo", "new-page"];
+$typedlinks{"bar"}={tag => {"Foo" => 1}};
 $links{"bar.png"}=[];
-$depends{"Foo"}=[];
-$depends{"bar"}=["foo*"];
-$depends{"bar.png"}=[];
+$depends{"Foo"}={};
+$depends{"bar"}={"foo*" => 1};
+$depends{"bar.png"}={};
 $pagestate{"bar"}{meta}{title}="a page about bar";
 $pagestate{"bar"}{meta}{moo}="mooooo";
-# only loaded plugins save state, so this should not be saved out
-$pagestate{"bar"}{nosuchplugin}{moo}="mooooo";
 
 ok(saveindex(), "save index");
 ok(-s "$config{wikistatedir}/indexdb", "index file created");
 
 # Clear state.
 %oldrenderedfiles=%pagectime=();
-%pagesources=%pagemtime=%oldlinks=%links=%depends=
+%pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks=
 %destsources=%renderedfiles=%pagecase=%pagestate=();
 
 ok(loadindex(), "load index");
@@ -80,9 +79,9 @@ is_deeply(\%links, {
        "bar.png" => [],
 }, "%links loaded correctly");
 is_deeply(\%depends, {
-       Foo => [],
-       bar => ["foo*"],
-       "bar.png" => [],
+       Foo => {},
+       bar => {"foo*" => 1},
+       "bar.png" => {},
 }, "%depends loaded correctly");
 is_deeply(\%pagestate, {
        bar => {
@@ -104,17 +103,26 @@ is_deeply(\%destsources, {
        "sparkline-foo.gif" => "bar",
        "bar.png" => "bar.png",
 }, "%destsources generated correctly");
+is_deeply(\%typedlinks, {
+       bar => {tag => {"Foo" => 1}},
+}, "%typedlinks loaded correctly");
+is_deeply(\%oldtypedlinks, {
+       bar => {tag => {"Foo" => 1}},
+}, "%oldtypedlinks loaded correctly");
 
 # Clear state.
 %oldrenderedfiles=%pagectime=();
-%pagesources=%pagemtime=%oldlinks=%links=%depends=
+%pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks=
 %destsources=%renderedfiles=%pagecase=%pagestate=();
 
-# When state is loaded for a wiki rebuild, only ctime and oldrenderedfiles
-# are retained.
+# When state is loaded for a wiki rebuild, only ctime, oldrenderedfiles,
+# and pagesources are retained.
 $config{rebuild}=1;
 ok(loadindex(), "load index");
 is_deeply(\%pagesources, {
+       Foo => "Foo.mdwn",
+       bar => "bar.mdwn",
+       "bar.png" => "bar.png",
 }, "%pagesources loaded correctly");
 is_deeply(\%pagemtime, {
 }, "%pagemtime loaded correctly");
@@ -136,9 +144,16 @@ is_deeply(\%depends, {
 }, "%depends loaded correctly");
 is_deeply(\%pagestate, {
 }, "%pagestate loaded correctly");
-is_deeply(\%pagecase, {
+is_deeply(\%pagecase, { # generated implicitly since pagesources is loaded
+       foo => "Foo",
+       bar => "bar",
+       "bar.png" => "bar.png"
 }, "%pagecase generated correctly");
 is_deeply(\%destsources, {
 }, "%destsources generated correctly");
+is_deeply(\%typedlinks, {
+}, "%typedlinks cleared correctly");
+is_deeply(\%oldtypedlinks, {
+}, "%oldtypedlinks cleared correctly");
 
 system "rm -rf $config{wikistatedir}";