despam.t 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (C) 2006, 2007 Alex Schroeder <alex@emacswiki.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. require './t/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 13;
  18. add_module('despam.pl');
  19. update_page('HilariousPage', "Ordinary text.");
  20. update_page('HilariousPage', "Hilarious text.");
  21. update_page('HilariousPage', "Spam from http://example.com.");
  22. update_page('NoPage', "Spam from http://example.com.");
  23. update_page('OrdinaryPage', "Spam from http://example.com.");
  24. update_page('OrdinaryPage', "Ordinary text.");
  25. update_page('ExpiredPage', "Spam from http://example.com.");
  26. update_page('ExpiredPage', "More spam from http://example.com.");
  27. update_page('ExpiredPage', "Still more spam from http://example.com.");
  28. update_page('BannedContent', " example\\.com\n", 'required', 0, 1);
  29. unlink("$DataDir/keep/ExpiredPage/1.kp")
  30. or die "Cannot delete kept revision: $!";
  31. my $page = get_page('action=spam');
  32. test_page($page, 'HilariousPage', 'NoPage', 'ExpiredPage');
  33. test_page_negative($page, 'OrdinaryPage');
  34. test_page(get_page('action=despam'), 'HilariousPage.*Revert to revision 2',
  35. 'NoPage.*Marked as DeletedPage', 'OrdinaryPage',
  36. 'ExpiredPage.*Cannot find unspammed revision');
  37. test_page(get_page('ExpiredPage'), 'Still more spam');
  38. test_page(get_page('OrdinaryPage'), 'Ordinary text');
  39. test_page(get_page('NoPage'), 'DeletedPage');
  40. test_page(get_page('HilariousPage'), 'Hilarious text');
  41. test_page(get_page('BannedContent'), 'example\\\.com');