upgrade.t 4.2 KB

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