Almost-minimal filesystem based blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.6 KiB

  1. #!/usr/bin/perl
  2. =pod
  3. =head1 NAME
  4. test.pl - a set of basic tests for display
  5. =head1 SYNOPSIS
  6. Given a working installation and configuration file:
  7. ./test.pl
  8. =head1 DESCRIPTION
  9. This section to-come.
  10. =head1 MISSING TESTS
  11. These items aren't tested at all, at the moment. A number of them aren't
  12. particularly trivial to test.
  13. sub get_diff
  14. sub get_latest_diff_date
  15. sub write_page
  16. sub add_to_page
  17. sub log_page_edit
  18. sub parse_cookies
  19. sub write_cookies_to_browser
  20. sub setup
  21. sub parse_parameters
  22. sub write_diff
  23. sub merge_diff
  24. =head1 SEE ALSO
  25. validate.pl in the WalaWiki distribution.
  26. =cut
  27. use strict;
  28. use warnings;
  29. use lib 'lib';
  30. #use Test::HTML::W3C 'show_detail';
  31. use Test::Simple tests => 10;
  32. use Wala qw(%WalaConf %DISPLAY_CONF);
  33. # TESTS
  34. section ('configuration');
  35. ok (Wala::eval_file("p1k3.conf.pl"), "eval_file on p1k3.conf.pl");
  36. ok (defined %WalaConf, 'External configuration hash defined.');
  37. section ('individual subroutine tests');
  38. # This will turn off stuff that breaks testing.
  39. $WalaConf{TestMode} = 1;
  40. ok (Wala::get_username eq $WalaConf{'DefaultUserName'},
  41. "get_username returns default.");
  42. ok (Wala::get_mtime('Wala.pm') =~ m/\d+/,
  43. 'get_mtime returns digits.');
  44. ok (Wala::mygmtime(0) eq 'Thu, 01-Jan-1970 00:00:00 GMT',
  45. 'mygmtime(0) returns epoch');
  46. # Hack. Depends on ./log
  47. LOGFILE: {
  48. local $WalaConf{RootDir} = "./";
  49. ok (Wala::recent_changes(1) =~ m/\d+ \w+ \w+.*$/,
  50. 'recent_changes(1) returns an appropriate logfile line.');
  51. }
  52. ok (Wala::spamcheck("http://spamcheckfunction.com", "TEST", "TEST") == 1,
  53. 'spamcheck trips on a URL');
  54. section ('starting link code testing');
  55. ok (
  56. Wala::make_links_of_wiki_words('TestWord')
  57. =~ m/<a href="$WalaConf{ScriptName}\?.*?TestWord"/,
  58. 'Return link for TestWord'
  59. );
  60. ok (
  61. Wala::get_bracketed_link("[http://p1k3.com/ p1k3]")
  62. eq "<a href=\"http://p1k3.com/\" class=\"external\">p1k3</a>",
  63. 'Return bracketed link'
  64. );
  65. # this isn't doing what I'd like it to.
  66. ok (
  67. Wala::pagelinks('PageLink [other page link]'),
  68. 'Pagelinks sub finds ' . Wala::pagelinks('PageLink [other page link]') . ' links'
  69. );
  70. # END OF TESTS
  71. # Utility routines.
  72. sub hash_print {
  73. my %hash = @_;
  74. my $string;
  75. for my $key (keys %hash) {
  76. $string .= "\n$key: $hash{$key}";
  77. }
  78. return $string;
  79. }
  80. sub pause {
  81. my $time = shift;
  82. #print " pausing $time seconds\n";
  83. sleep $time;
  84. }
  85. sub section {
  86. my $msg = shift;
  87. print "\n-- $msg --\n\n";
  88. }