]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Add unit tests for several core functions, including globlist_match,
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 2 May 2006 21:14:50 +0000 (21:14 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 2 May 2006 21:14:50 +0000 (21:14 +0000)
  dirname, basename, and bestlink.
  as plugins and work. (Well, in theory.)

debian/changelog
t/bestlink.t [new file with mode: 0755]

index c9d9ab1e0fa0634228431288873e482f9b650553..c072c237b3a3dbc7f600edcf9fab291d448f2e0d 100644 (file)
@@ -26,7 +26,8 @@ ikiwiki (1.1) UNRELEASED; urgency=low
   * Removed backlinks page, which it turns out nothing used.
   * Split off an IkiWiki.pm out of ikiwiki and have all the other modules use
     it, this will allow for adding a unit test suite.
   * Removed backlinks page, which it turns out nothing used.
   * Split off an IkiWiki.pm out of ikiwiki and have all the other modules use
     it, this will allow for adding a unit test suite.
-  * Add a unit test for globlist_match().
+  * Add unit tests for several core functions, including globlist_match,
+    dirname, basename, and bestlink.
   * Smart globlist merging.
   * Patch from Thomas Schwinge to switch from --svn to --rcs=svn, etc,
     to pave the way for adding other RCS support. This also changes the
   * Smart globlist merging.
   * Patch from Thomas Schwinge to switch from --svn to --rcs=svn, etc,
     to pave the way for adding other RCS support. This also changes the
@@ -34,7 +35,7 @@ ikiwiki (1.1) UNRELEASED; urgency=low
     rcs => "svn" or rcs => "".
   * Add a debian/NEWS file with upgrade notes.
   * Load whatever rcs module is specified, so new ones can be just dropped in
     rcs => "svn" or rcs => "".
   * Add a debian/NEWS file with upgrade notes.
   * Load whatever rcs module is specified, so new ones can be just dropped in
-    as plugins and work.
+    as plugins and work. (Well, in theory.)
   * Add some basic docs about writing RCS modules.
 
  -- Joey Hess <joeyh@debian.org>  Tue,  2 May 2006 14:13:59 -0400
   * Add some basic docs about writing RCS modules.
 
  -- Joey Hess <joeyh@debian.org>  Tue,  2 May 2006 14:13:59 -0400
diff --git a/t/bestlink.t b/t/bestlink.t
new file mode 100755 (executable)
index 0000000..ed748b0
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 5;
+
+sub test ($$$) {
+       my $page=shift;
+       my $link=shift;
+       my @existing_pages=@{shift()};
+       
+       %IkiWiki::links=();
+       foreach my $page (@existing_pages) {
+               $IkiWiki::links{$page}=[];
+       }
+
+       return IkiWiki::bestlink($page, $link);
+}
+
+BEGIN { use_ok("IkiWiki"); }
+
+is(test("bar", "foo", ["bar"]), "", "broken link");
+is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link");
+is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link");
+is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");