summaryrefslogtreecommitdiff
path: root/test/tc_config.rb
blob: ba70b330e4b8d99d6ad097a9db44f0c635b426e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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