summaryrefslogtreecommitdiff
path: root/t/test-custodian-settings.rb
blob: 16308591871107c6f6da3655591c39cac633ea17 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/ruby -I./lib/ -I../lib/


require 'custodian/settings'
require 'test/unit'



#
# Unit test for our configuration file reader.
#
#
class TestConfigurationSingleton < Test::Unit::TestCase

  #
  # Create the test suite environment: NOP.
  #
  def setup
  end

  #
  # Destroy the test suite environment: NOP.
  #
  def teardown
  end


  #
  # Test that we're genuinely a singleton
  #
  def test_singleton
    a = Custodian::Settings.instance
    b = Custodian::Settings.instance

    assert(a)
    assert(b)
    assert_equal(a.object_id, b.object_id)
  end


  #
  #  Test that our settings are suitable types
  #
  def test_types
    settings = Custodian::Settings.instance


    # retry delay - probably unset.
    a = settings.retry_delay
    assert(a.class == Integer ||
           a.class == Fixnum)

    # store a number
    settings._store('retry_delay', 5)
    a = settings.retry_delay
    assert(a.class == Integer || a.class == Fixnum )
    assert(a == 5)

    # store a string
    settings._store('retry_delay', '35')
    a = settings.retry_delay
    assert(a.class == Integer || a.class == Fixnum )
    assert(a == 35)



    # timeout - probably unset.
    a = settings.timeout
    assert(a.class == Integer || a.class == Fixnum )

    # store a number
    settings._store('timeout', 5)
    a = settings.timeout
    assert(a.class == Integer || a.class == Fixnum )
    assert(a == 5)

    # store a string
    settings._store('timeout', '35')
    a = settings.timeout
    assert(a.class == Integer || a.class == Fixnum )
    assert(a == 35)


  end

end