summaryrefslogtreecommitdiff
path: root/t/apache404.t
blob: 00fc3525004fd1e2fc063b26bc4f5c4146fa6271 (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More tests => 17;
  5. BEGIN { use_ok("IkiWiki::Plugin::apache404"); }
  6. sub cgi_page_from_404 {
  7. return IkiWiki::Plugin::apache404::cgi_page_from_404(shift, shift,
  8. shift);
  9. }
  10. $IkiWiki::config{htmlext} = 'html';
  11. is(cgi_page_from_404('/', 'http://example.com', 1), 'index');
  12. is(cgi_page_from_404('/index.html', 'http://example.com', 0), 'index');
  13. is(cgi_page_from_404('/', 'http://example.com/', 1), 'index');
  14. is(cgi_page_from_404('/index.html', 'http://example.com/', 0), 'index');
  15. is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user', 1),
  16. 'foo/bar');
  17. is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user', 1),
  18. 'foo/bar');
  19. is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user', 1),
  20. 'foo/bar');
  21. is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user', 0),
  22. 'foo/bar');
  23. is(cgi_page_from_404('/~user/foo/bar', 'http://example.com/~user/', 1),
  24. 'foo/bar');
  25. is(cgi_page_from_404('/~user/foo/bar/index.html', 'http://example.com/~user/', 1),
  26. 'foo/bar');
  27. is(cgi_page_from_404('/~user/foo/bar/', 'http://example.com/~user/', 1),
  28. 'foo/bar');
  29. is(cgi_page_from_404('/~user/foo/bar.html', 'http://example.com/~user/', 0),
  30. 'foo/bar');
  31. is(cgi_page_from_404('/~user/foo', 'https://example.com/~user', 1),
  32. 'foo');
  33. is(cgi_page_from_404('/~user/foo/index.html', 'https://example.com/~user', 1),
  34. 'foo');
  35. is(cgi_page_from_404('/~user/foo/', 'https://example.com/~user', 1),
  36. 'foo');
  37. is(cgi_page_from_404('/~user/foo.html', 'https://example.com/~user', 0),
  38. 'foo');