aboutsummaryrefslogtreecommitdiff
path: root/test/tc_mauve_configuration_builder.rb
blob: faa0bfacd9736d0c3e3c3bf5dd5743e5167bd2bb (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
$:.unshift "../lib/"

require 'th_mauve'
require 'mauve/configuration_builder'

class TcMauveConfigurationBuildersPeopleAndSourceLists < Mauve::UnitTest

  def setup
    setup_logger
  end

  def teardown
    teardown_logger
  end

  def test_people_list
    config =<<EOF
people_list "team sky", %w(
  geraint
  edvald
  bradley
  rigoberto
  ben
)

people_list "garmin-cervelo", %w(
  thor
  ryder
  tyler
  julian
)

EOF
    x = nil
    assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) }
    assert_equal(2, x.people_lists.keys.length)
    assert_equal(["team sky","garmin-cervelo"].sort,x.people_lists.keys.sort)
    assert_equal(%w(geraint edvald bradley rigoberto ben), x.people_lists["team sky"].list)

  end

  def test_duplicate_people_list

    config=<<EOF

people_list "htc-highroad", 
  ["mark c", "mark r", "Lars"]

people_list "htc-highroad",
  %w(Bernie Danny Lars)

EOF
    x = nil
    #
    # This should generate two warnings:
    #   * duplicate list
    #   * Lars already being on a list
    #
    assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) }

    assert_match(/Lars/,      logger_pop())
    assert_match(/Duplicate/, logger_pop())

    assert_equal(1, x.people_lists.keys.length)
    assert_equal(["mark c","mark r","Lars","Bernie","Danny"].sort, x.people_lists["htc-highroad"].list.sort)
  end

  def test_source_list
    config =<<EOF
source_list "sources", %w(
  test-1.example.com
  imaginary.host.example.com
  192.168.100.1/24
  *.imaginary.example.com
)
EOF

    x = nil
    assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) }

    x.source_lists["sources"].resolve
  end

end