git.t 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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, but
  9. # WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # 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 => 16;
  18. use utf8; # test data is UTF-8 and it matters
  19. SKIP: {
  20. test_page(update_page('Legacy', 'an old page'), 'an old page');
  21. add_module('git.pl');
  22. $ENV{LANG} = "en_US.UTF-8"; # test relies on English output
  23. if (qx($GitBinary --version) !~ /git version/) {
  24. skip "$GitBinary not found", 16;
  25. }
  26. GitInitVariables();
  27. test_page(update_page('Test', 'Something'), # default summary = page text
  28. 'Something');
  29. test_page(update_page('Test', 'Some other thing', 'a summary is provided'),
  30. 'Some other thing');
  31. test_page(update_page('Test', 'No summary is provided'),
  32. 'No summary is provided');
  33. # Use GitRun so that git gets to run inside $GitRepo. Use $GitResult
  34. # to peek at the stdout of the git command. This is probably
  35. # clobbered in a mod_perl environment.
  36. $GitDebug = 1;
  37. $GitResult = '';
  38. GitRun(qw(status));
  39. test_page($GitResult, 'nothing to commit', 'working directory clean');
  40. GitRun(qw(log -- Test));
  41. test_page($GitResult,
  42. 'Author: Anonymous <unknown\@oddmuse.org>',
  43. ' Something',
  44. ' a summary is provided',
  45. ' no summary available');
  46. test_page_negative($GitResult,
  47. 'initial import');
  48. GitRun(qw(log -- Legacy));
  49. test_page($GitResult,
  50. 'Author: Oddmuse <unknown\@oddmuse.org>',
  51. 'initial import');
  52. # use username Alex to save a new revision
  53. get_page("title=Test text=Otherness username=Alex");
  54. test_page(get_page('Test'), 'Otherness');
  55. GitRun(qw(log));
  56. test_page($GitResult, 'Author: Alex <unknown\@oddmuse.org>');
  57. # one for every update_page and one for the get_page with username
  58. my @matches = $GitResult =~ /commit/g;
  59. ok(scalar(@matches) == 5, "number of commits adds up");
  60. }