upgrade.t 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # Copyright (C) 2014 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 => 47;
  18. # Perl 5.26 removed . from @INC but we don't want to change oddmuse-2.2.6.pl, if
  19. # possible.
  20. $ENV{'PERL5LIB'} = '.';
  21. # Create a 2.2.6 wiki first.
  22. $page = qx(perl t/oddmuse-2.2.6.pl title=Test text=Hello);
  23. test_page($page, "Status: 302 Found");
  24. $page = qx(perl t/oddmuse-2.2.6.pl title=Test text=Hallo);
  25. test_page($page, "Status: 302 Found");
  26. $page = qx(perl t/oddmuse-2.2.6.pl title=.hidden text=Hello);
  27. test_page($page, "Status: 302 Found");
  28. $page = qx(perl t/oddmuse-2.2.6.pl title=.hidden text=Hallo);
  29. test_page($page, "Status: 302 Found");
  30. $page = qx(perl t/oddmuse-2.2.6.pl action=pagelock id=Test set=1 pwd=foo);
  31. test_page($page, "created");
  32. ok(-d "$PageDir/T", "T page directory exists");
  33. ok(-d "$KeepDir/T", "T keep directory exists");
  34. ok(-d "$PageDir/other", "other page directory exists");
  35. ok(-d "$KeepDir/other", "other keep directory exists");
  36. add_module('upgrade.pl');
  37. ok(-f "$ModuleDir/upgrade.pl", "upgrade.pl was installed");
  38. test_page(get_page('Test'), 'Upgrading Database', 'action=password');
  39. test_page(get_page('action=password'), 'You are a normal user');
  40. $page = get_page('action=upgrade pwd=foo');
  41. test_page($page,
  42. 'page/T/Test.pg',
  43. 'page/T/Test.lck',
  44. 'keep/T/Test',
  45. 'page/other/.hidden.pg',
  46. 'keep/other/.hidden',
  47. 'Upgrade complete');
  48. test_page_negative($page, 'failed',
  49. 'does not fit the pattern',
  50. 'Please remove');
  51. ok(! -d "$PageDir/T", "T directory has disappeared");
  52. ok(! -d "$KeepDir/T", "T keep directory has disappeared");
  53. ok(! -d $LockDir . 'main', "Lock was released");
  54. ok(! -f "$ModuleDir/upgrade.pl", "upgrade.pl was renamed");
  55. test_page(get_page('action=browse id=Test revision=1'), 'Hello');
  56. test_page(get_page('Test'), 'Hallo');
  57. test_page(get_page('.hidden'), 'Hallo');
  58. # you cannot run it again after a successful run
  59. test_page(get_page('action=upgrade pwd=foo'),
  60. 'Invalid action parameter');
  61. # reinstall it and run it again
  62. add_module('upgrade.pl');
  63. test_page(get_page('action=upgrade pwd=foo'),
  64. 'Upgrade complete');
  65. # set up a wiki with namespaces
  66. clear_pages();
  67. # install the old revision of namespaces.pl; we cannot use add_module
  68. # because the old revision is stored in the t subdirectory.
  69. my $dir = `/bin/pwd`;
  70. chop($dir);
  71. my $mod = 'namespaces-2.2.6.pl';
  72. mkdir($ModuleDir);
  73. symlink("$dir/t/$mod", "$ModuleDir/$mod");
  74. ok(-e "$ModuleDir/$mod", "old namespaces.pl installed");
  75. test_page(qx(perl t/oddmuse-2.2.6.pl title=Test text=Main%20Hello),
  76. "Status: 302 Found", "Location: http://localhost/wiki.pl/Test");
  77. test_page(qx(perl t/oddmuse-2.2.6.pl title=Test text=Space%20Hello ns=Space),
  78. "Status: 302 Found", "Location: http://localhost/wiki.pl/Space/Test");
  79. add_module('upgrade.pl');
  80. $page = get_page('action=upgrade pwd=foo');
  81. test_page($page,
  82. '<strong>Space</strong>',
  83. 'Upgrade complete');
  84. test_page_negative($page, 'failed');
  85. test_page(get_page('Test'), 'Main Hello');
  86. test_page(get_page("'/Space/Test?'"), 'Space Hello');
  87. # Install modules which use GetPageContent in their init routine.
  88. clear_pages();
  89. test_page(qx(perl t/oddmuse-2.2.6.pl title=$InterMap text=$InterMap),
  90. $InterMap);
  91. add_module('localnames.pl');
  92. test_page(qx(perl t/oddmuse-2.2.6.pl title=$LocalNamesPage text=$LocalNamesPage),
  93. $LocalNamesPage);
  94. add_module('sidebar.pl');
  95. test_page(qx(perl t/oddmuse-2.2.6.pl title=$SidebarName text=$SidebarName),
  96. $SidebarName);
  97. add_module('near-links.pl');
  98. test_page(qx(perl t/oddmuse-2.2.6.pl title=$NearMap text=$NearMap),
  99. $NearMap);
  100. add_module('upgrade.pl');
  101. test_page_negative(get_page('HomePage'), 'Cannot open');
  102. test_page(get_page('action=upgrade pwd=foo'),
  103. 'Upgrade complete');