google-search.t 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright (C) 2007 Alex Schroeder <alex@emacswiki.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 => 9;
  18. add_module('google-search.pl');
  19. GoogleSearchInit();
  20. is($GoogleSearchDomain, undef, 'No $ScriptName');
  21. $GoogleSearchDomain = undef;
  22. $ScriptName = 'http://www.communitywiki.org/en';
  23. GoogleSearchInit();
  24. is($GoogleSearchDomain, 'communitywiki.org', $ScriptName);
  25. $GoogleSearchDomain = undef;
  26. $ScriptName = 'http://www.community.org:80/';
  27. GoogleSearchInit();
  28. is($GoogleSearchDomain, 'community.org', $ScriptName);
  29. $GoogleSearchDomain = undef;
  30. $ScriptName = 'http://www.communitywiki.org';
  31. GoogleSearchInit();
  32. is($GoogleSearchDomain, 'communitywiki.org', $ScriptName);
  33. $GoogleSearchDomain = undef;
  34. $ScriptName = 'http://emacswiki.org/cgi-bin/emacs';
  35. GoogleSearchInit();
  36. is($GoogleSearchDomain, 'emacswiki.org', $ScriptName);
  37. $GoogleSearchDomain = undef;
  38. $ScriptName = 'http://localhost/wiki.pl';
  39. GoogleSearchInit();
  40. isnt($GoogleSearchDomain, 'localhost', $ScriptName);
  41. test_page(get_page('search=alex'),
  42. '<title>Wiki: Search for: alex</title>');
  43. AppendStringToFile($ConfigFile, "\$ScriptName = 'http://emacswiki.org/';\n");
  44. test_page(get_page('search=alex'),
  45. 'Status: 302',
  46. 'Location: http://www.google.com/search\?q=site%3Aemacswiki.org\+alex');