google-search.t 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 2 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, write to the
  15. # Free Software Foundation, Inc.
  16. # 59 Temple Place, Suite 330
  17. # Boston, MA 02111-1307 USA
  18. require 't/test.pl';
  19. package OddMuse;
  20. use Test::More tests => 9;
  21. add_module('google-search.pl');
  22. GoogleSearchInit();
  23. is($GoogleSearchDomain, undef, 'No $ScriptName');
  24. $GoogleSearchDomain = undef;
  25. $ScriptName = 'http://www.communitywiki.org/en';
  26. GoogleSearchInit();
  27. is($GoogleSearchDomain, 'communitywiki.org', $ScriptName);
  28. $GoogleSearchDomain = undef;
  29. $ScriptName = 'http://www.community.org:80/';
  30. GoogleSearchInit();
  31. is($GoogleSearchDomain, 'community.org', $ScriptName);
  32. $GoogleSearchDomain = undef;
  33. $ScriptName = 'http://www.communitywiki.org';
  34. GoogleSearchInit();
  35. is($GoogleSearchDomain, 'communitywiki.org', $ScriptName);
  36. $GoogleSearchDomain = undef;
  37. $ScriptName = 'http://emacswiki.org/cgi-bin/emacs';
  38. GoogleSearchInit();
  39. is($GoogleSearchDomain, 'emacswiki.org', $ScriptName);
  40. $GoogleSearchDomain = undef;
  41. $ScriptName = 'http://localhost/wiki.pl';
  42. GoogleSearchInit();
  43. isnt($GoogleSearchDomain, 'localhost', $ScriptName);
  44. test_page(get_page('search=alex'),
  45. '<title>Wiki: Search for: alex</title>');
  46. AppendStringToFile($ConfigFile, "\$ScriptName = 'http://emacswiki.org/';\n");
  47. test_page(get_page('search=alex'),
  48. 'Status: 302',
  49. 'Location: http://www.google.com/search\?q=site%3Aemacswiki.org\+alex');