maintain.t 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (C) 2009–2015 Alex Schroeder <alex@gnu.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 => 10;
  18. # old log entry to be moved
  19. my $log = join($FS, '1235079422', 'Ganz_und_Gar', '',
  20. 'Ladenbeschreibung und Preisliste', '62.12.165.34',
  21. 'Alex', '1', '', '');
  22. WriteStringToFile($RcFile, $log . "\n");
  23. test_page(get_page('action=maintain pwd=foo'),
  24. 'Moving 1 log entries');
  25. test_page(ReadFileOrDie($RcOldFile),
  26. "^1235079422$FS");
  27. is(ReadFileOrDie($RcFile), '', 'empty rc.log');
  28. update_page('test', 'this is a test');
  29. my $log = ReadFileOrDie($RcFile);
  30. test_page($log,
  31. "${FS}test${FS}",
  32. "${FS}this is a test${FS}");
  33. test_page_negative($log, "^\n");
  34. # old page to be deleted
  35. OpenPage('test');
  36. $Page{ts} = 1;
  37. $Page{revision} = 1;
  38. $Page{text} = $DeletedPage;
  39. SavePage();
  40. AppendStringToFile($ConfigFile, "\$KeepDays = 14;\n");
  41. ok(-f GetPageFile($OpenPageName), GetPageFile($OpenPageName)
  42. . " exists");
  43. xpath_test(get_page('action=maintain pwd=foo'),
  44. '//a[text()="test"]/following-sibling::text()[.=" deleted"]');
  45. ok(! -e GetPageFile($OpenPageName), GetPageFile($OpenPageName)
  46. . " was deleted");
  47. my $data = ReadFileOrDie($DeleteFile);
  48. ok($data eq "test\n", "Delete was logged");