summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtest/tc_httpfetcher.rb66
-rwxr-xr-xtest/tc_mail.rb2
-rwxr-xr-xtest/ts_feed2imap.rb5
3 files changed, 72 insertions, 1 deletions
diff --git a/test/tc_httpfetcher.rb b/test/tc_httpfetcher.rb
new file mode 100755
index 0000000..d44b3ee
--- /dev/null
+++ b/test/tc_httpfetcher.rb
@@ -0,0 +1,66 @@
+#!/usr/bin/ruby
+
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+
+require 'test/unit'
+require 'feed2imap/httpfetcher'
+
+class HttpFetcherTest < Test::Unit::TestCase
+ def test_get_https
+ s = ''
+ assert_nothing_raised do
+ s = HTTPFetcher::fetch('https://linuxfr.org/pub/', Time::at(0))
+ end
+ assert(s.length > 20)
+ end
+
+ def test_get_http
+
+ end
+
+ def test_get_httpnotmodif
+ s = 'aaa'
+ assert_nothing_raised do
+ s = HTTPFetcher::fetch('http://www.lucas-nussbaum.net/feed2imap_tests/notmodified.php', Time::new())
+ end
+ assert_nil(s)
+ end
+
+ def test_get_redir1
+ s = 'aaa'
+ assert_nothing_raised do
+ s = HTTPFetcher::fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR}", Time::at(0))
+ end
+ assert_equal('OK', s)
+ end
+
+ def test_get_redir2
+ s = ''
+ assert_raise(RuntimeError) do
+ s = HTTPFetcher::fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR + 1}", Time::at(0))
+ end
+ end
+
+ def test_httpauth
+ s = ''
+ assert_nothing_raised do
+ s = HTTPFetcher::fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php", Time::at(0))
+ end
+ assert_equal("Login: aaa / Password: bbb \n", s)
+ end
+
+ def test_redirauth
+ s = ''
+ assert_nothing_raised do
+ s = HTTPFetcher::fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php?redir=1", Time::at(0))
+ end
+ assert_equal("Login: aaa / Password: bbb \n", s)
+ end
+
+ def test_notfound
+ s = ''
+ assert_raises(RuntimeError) do
+ s = HTTPFetcher::fetch("http://ensilinx1.imag.fr/~lucas/notfound.html", Time::at(0))
+ end
+ end
+end
diff --git a/test/tc_mail.rb b/test/tc_mail.rb
index d3b99fd..3b700df 100755
--- a/test/tc_mail.rb
+++ b/test/tc_mail.rb
@@ -6,7 +6,7 @@ require 'test/unit'
require 'feed2imap/channel'
require 'rmail'
-class ConfigTest < Test::Unit::TestCase
+class MailTest < Test::Unit::TestCase
def test_require_rmail
# let's just test Rubymail is loaded
m = RMail::Message::new
diff --git a/test/ts_feed2imap.rb b/test/ts_feed2imap.rb
index fdea1a3..3e3aa08 100755
--- a/test/ts_feed2imap.rb
+++ b/test/ts_feed2imap.rb
@@ -1,7 +1,11 @@
#!/usr/bin/ruby -w
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+$:.unshift File.join(File.dirname(__FILE__), '..', 'test')
+$:.unshift File.join(File.dirname(__FILE__), 'lib')
+$:.unshift File.join(File.dirname(__FILE__), 'test')
+require 'feed2imap'
require 'tc_cache'
require 'tc_channel_parse'
require 'tc_config'
@@ -10,3 +14,4 @@ require 'tc_converters_toutf8'
require 'tc_parser'
require 'tc_converters_text2html'
require 'tc_mail'
+require 'tc_httpfetcher'