]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - t/cvs.t
Test checkconfig().
[git.ikiwiki.info.git] / t / cvs.t
diff --git a/t/cvs.t b/t/cvs.t
index cae3f8dc393c0008c50e268bb8dc44e54844afae..9efe1caaef2029d9ac2dd7dad1c7e7e14a54fd77 100755 (executable)
--- a/t/cvs.t
+++ b/t/cvs.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More; my $total_tests = 52;
+use Test::More; my $total_tests = 53;
 use IkiWiki;
 
 my $default_test_methods = '^test_*';
@@ -62,6 +62,7 @@ sub test_cvs_run_cvsps {
        # parameterize command like run_cvs()
        # expose config vars for e.g. "--cvs-direct -z 30"
        # always pass -x (unless proven otherwise)
+       # - but diff doesn't! optimization alert
        # always pass -b HEAD (configurable like gitmaster_branch?)
 }
 
@@ -98,20 +99,38 @@ sub test_cvs_is_controlling {
 # TESTS FOR GENERAL PLUGIN API CALLS
 
 sub test_checkconfig {
-       # undef cvspath, expect "ikiwiki"
-       # define cvspath normally, get it back
-       # define cvspath in a subdir, get it back?
-       # define cvspath with extra slashes, get sanitized version back
-       # - yoink test_extra_path_slashes
-       # undef cvs_wrapper, expect $config{wrappers} same size as before
-
-       my $initial_cvspath = $config{cvspath};
-       $config{cvspath} = "/ikiwiki//";
+       my $default_cvspath = 'ikiwiki';
+
+       undef $config{cvspath}; IkiWiki::checkconfig();
+       is(
+               $config{cvspath}, $default_cvspath,
+               q{can provide default cvspath},
+       );
+
+       $config{cvspath} = "/$default_cvspath/"; IkiWiki::checkconfig();
+       is(
+               $config{cvspath}, $default_cvspath,
+               q{can set typical cvspath and strip well-meaning slashes},
+       );
+
+       $config{cvspath} = "/$default_cvspath//subdir"; IkiWiki::checkconfig();
+       is(
+               $config{cvspath}, "$default_cvspath/subdir",
+               q{can really sanitize cvspath as assumed by rcs_recentchanges},
+       );
+
+       my $default_num_wrappers = @{$config{wrappers}};
+       undef $config{cvs_wrapper}; IkiWiki::checkconfig();
+       is(
+               @{$config{wrappers}}, $default_num_wrappers,
+               q{can start with no wrappers configured},
+       );
+
+       $config{cvs_wrapper} = $config{cvsrepo} . "/CVSROOT/post-commit";
        IkiWiki::checkconfig();
        is(
-               $config{cvspath},
-               $initial_cvspath,
-               q{rcs_recentchanges assumes checkconfig has sanitized cvspath},
+               @{$config{wrappers}}, ++$default_num_wrappers,
+               q{can add cvs_wrapper},
        );
 }
 
@@ -170,9 +189,14 @@ sub test_rcs_add {
 
        my $message = "add a top-level ASCII (non-UTF-8) page via VCS API";
        my $file = q{test0.mdwn};
-       add_and_commit($file, $message, q{* some plain ASCII text});
+       add_and_commit($file, $message, qq{# \$Id\$\n* some plain ASCII text});
        is_newly_added($file);
        is_in_keyword_substitution_mode($file, undef);
+       like(
+               readfile($config{srcdir} . "/$file"),
+               qr/^# \$Id: $file,v 1.1 .+\$$/m,
+               q{can expand RCS Id keyword},
+       );
        @changes = IkiWiki::rcs_recentchanges(3);
        is_total_number_of_changes(\@changes, 1);
        is_most_recent_change(\@changes, stripext($file), $message);