duckduckgo-search.t 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (C) 2007–2013 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software: you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation, either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. require './t/test.pl';
  15. package OddMuse;
  16. use Test::More tests => 9;
  17. add_module('duckduckgo-search.pl');
  18. DuckDuckGoSearchInit();
  19. is($DuckDuckGoSearchDomain, undef, 'No $ScriptName');
  20. $DuckDuckGoSearchDomain = undef;
  21. $ScriptName = 'http://www.communitywiki.org/en';
  22. DuckDuckGoSearchInit();
  23. is($DuckDuckGoSearchDomain, 'communitywiki.org', $ScriptName);
  24. $DuckDuckGoSearchDomain = undef;
  25. $ScriptName = 'http://www.community.org:80/';
  26. DuckDuckGoSearchInit();
  27. is($DuckDuckGoSearchDomain, 'community.org', $ScriptName);
  28. $DuckDuckGoSearchDomain = undef;
  29. $ScriptName = 'http://www.communitywiki.org';
  30. DuckDuckGoSearchInit();
  31. is($DuckDuckGoSearchDomain, 'communitywiki.org', $ScriptName);
  32. $DuckDuckGoSearchDomain = undef;
  33. $ScriptName = 'http://emacswiki.org/cgi-bin/emacs';
  34. DuckDuckGoSearchInit();
  35. is($DuckDuckGoSearchDomain, 'emacswiki.org', $ScriptName);
  36. $DuckDuckGoSearchDomain = undef;
  37. $ScriptName = 'http://localhost/wiki.pl';
  38. DuckDuckGoSearchInit();
  39. isnt($DuckDuckGoSearchDomain, 'localhost', $ScriptName);
  40. test_page(get_page('search=alex'),
  41. '<title>Wiki: Search for: alex</title>');
  42. AppendStringToFile($ConfigFile, "\$ScriptName = 'http://emacswiki.org/';\n");
  43. test_page(get_page('search=alex'),
  44. 'Status: 302',
  45. 'Location: https://duckduckgo.com/\?q=alex\+site%3Aemacswiki\.org');