upgrade-files.t 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Copyright (C) 2009 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. # Create a UseModWiki first.
  16. $_ = 'nocgi';
  17. require './t/usemod-1.0.4.pl';
  18. # wipe /tmp/mywikidb!
  19. use File::Path qw(remove_tree);
  20. remove_tree($UseModWiki::DataDir) if -d $UseModWiki::DataDir;
  21. package UseModWiki;
  22. InitRequest();
  23. InitLinkPatterns();
  24. $q->param('oldtime', '1');
  25. $q->param('title', 'TestPage');
  26. $q->param('text', 'Converting to Oddmuse');
  27. $q->param('summary', 'Last UseModWiki edit');
  28. {
  29. local *STDOUT;
  30. my $result;
  31. open(STDOUT, '>', \$result) or die "Can't open memory file: $!";
  32. DoOtherRequest();
  33. }
  34. require './t/test.pl';
  35. package OddMuse;
  36. $DataDir = $UseModWiki::DataDir;
  37. $ENV{WikiDataDir} = $DataDir;
  38. Init(); # again
  39. use Test::More tests => 11;
  40. # check whether old wiki was created successfully
  41. ok(-d $UseModWiki::DataDir, "$UseModWiki::DataDir created");
  42. ok(-f UseModWiki::GetPageFile('TestPage'), "TestPage was created");
  43. ok(-f $UseModWiki::RcFile, "log file was created");
  44. my $output = `perl stuff/upgrade-files.pl separator='UseMod 1.00' dir='$UseModWiki::DataDir' sure=yes`;
  45. test_page_negative($output, '"does not seem to be a data directory"');
  46. test_page($output, "Reading page " . UseModWiki::GetPageFile('TestPage'),
  47. "Writing " . GetPageFile('TestPage'),
  48. "Reading $UseModWiki::RcFile",
  49. "Writing $RcFile");
  50. test_page(get_page('action=browse id=TestPage raw=1'), 'Converting to Oddmuse');
  51. test_page(get_page('action=rc raw=1'), 'title: TestPage', 'description: Last UseModWiki edit');