summaryrefslogtreecommitdiff
path: root/test/tc_config.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/tc_config.rb')
-rwxr-xr-xtest/tc_config.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/tc_config.rb b/test/tc_config.rb
new file mode 100755
index 0000000..ba70b33
--- /dev/null
+++ b/test/tc_config.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/ruby -w
+
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+
+require 'test/unit'
+require 'feed2imap/config'
+require 'stringio'
+
+CONF1 = <<EOF
+cache: /home/lucas/.feed2imap_cachedatabase
+feeds:
+ - name: feed1
+ url: http://something
+ target: imap://login:pasword@ezaezae/Feeds/A
+ - name: feed2
+ url: http://something2
+ target: imap://login:pasword@ezaezae/Feeds/B
+EOF
+CONF2 = <<EOF
+feeds:
+ - name: feed1
+ url: http://something
+ target: imap://login:pasword@ezaezae/Feeds/A
+ - name: feed2
+ url: http://something2
+ target: imaps://login:pasword@ezaezae/Feeds/B
+EOF
+
+class ConfigTest < Test::Unit::TestCase
+ def test_cache
+ sio = StringIO::new CONF1
+ conf = F2IConfig::new(sio)
+ assert_equal('/home/lucas/.feed2imap_cachedatabase', conf.cache)
+ # testing default value
+ sio = StringIO::new CONF2
+ conf = F2IConfig::new(sio)
+ assert_equal(ENV['HOME'] + '/.feed2imap.cache', conf.cache)
+ end
+
+ def test_accounts
+ sio = StringIO::new CONF1
+ conf = F2IConfig::new(sio)
+ assert_equal(1, conf.imap_accounts.length)
+ sio = StringIO::new CONF2
+ conf = F2IConfig::new(sio)
+ assert_equal(2, conf.imap_accounts.length)
+ end
+end