summaryrefslogtreecommitdiff
path: root/t/svn.t
blob: 69ad5c29c18d389d079d1a174cabae246a4858c1 (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. my $dir;
  5. BEGIN {
  6. $dir="/tmp/ikiwiki-test-svn.$$";
  7. my $svn=`which svn`;
  8. chomp $svn;
  9. my $svnadmin=`which svnadmin`;
  10. chomp $svnadmin;
  11. if (! -x $svn || ! -x $svnadmin || ! mkdir($dir)) {
  12. eval q{
  13. use Test::More skip_all => "svn not available or could not make test dir"
  14. }
  15. }
  16. }
  17. use Test::More tests => 8;
  18. BEGIN { use_ok("IkiWiki"); }
  19. %config=IkiWiki::defaultconfig();
  20. $config{rcs} = "svn";
  21. $config{srcdir} = "$dir/src";
  22. $config{svnrepo} = "$dir/repo";
  23. $config{svnpath} = "trunk";
  24. IkiWiki::checkconfig();
  25. system "svnadmin create $config{svnrepo} >/dev/null";
  26. system "svn mkdir file://$config{svnrepo}/trunk -m add >/dev/null";
  27. system "svn co file://$config{svnrepo}/trunk $config{srcdir} >/dev/null";
  28. # Web commit
  29. my $test1 = readfile("t/test1.mdwn");
  30. writefile('test1.mdwn', $config{srcdir}, $test1);
  31. IkiWiki::rcs_add("test1.mdwn");
  32. IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo");
  33. my @changes;
  34. @changes = IkiWiki::rcs_recentchanges(3);
  35. is($#changes, 0);
  36. is($changes[0]{message}[0]{"line"}, "Added the first page");
  37. is($changes[0]{pages}[0]{"page"}, "test1.mdwn");
  38. # Manual commit
  39. my $message = "Added the second page";
  40. my $test2 = readfile("t/test2.mdwn");
  41. writefile('test2.mdwn', $config{srcdir}, $test2);
  42. system "svn add $config{srcdir}/test2.mdwn >/dev/null";
  43. system "svn commit $config{srcdir}/test2.mdwn -m \"$message\" >/dev/null";
  44. @changes = IkiWiki::rcs_recentchanges(3);
  45. is($#changes, 1);
  46. is($changes[0]{message}[0]{"line"}, $message);
  47. is($changes[0]{pages}[0]{"page"}, "test2.mdwn");
  48. is($changes[1]{pages}[0]{"page"}, "test1.mdwn");
  49. system "rm -rf $dir";