diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
commit | fd23821950f0562a8995735105cd31fdc6d55933 (patch) | |
tree | 967df2f5647803a6c46f4d52003b2231c1de72cb /test/tc_mauve_configuration_builder.rb | |
parent | d3a3cfef9650b08f62db62bd7e86b673f9d77d0b (diff) |
* Rejigged configuration
* Added --test and --verbose flags for the server config
* Started proper test suite
* Config parsing now gives more sensible errors + backtrace
* Rejigged people and source lists
Diffstat (limited to 'test/tc_mauve_configuration_builder.rb')
-rw-r--r-- | test/tc_mauve_configuration_builder.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/tc_mauve_configuration_builder.rb b/test/tc_mauve_configuration_builder.rb new file mode 100644 index 0000000..03b86ca --- /dev/null +++ b/test/tc_mauve_configuration_builder.rb @@ -0,0 +1,72 @@ +$:.unshift "../lib/" + +require 'test/unit' +require 'pp' +require 'mauve/configuration_builder' + +class TcMauveConfigurationBuildersPeopleAndSourceLists < Test::Unit::TestCase + + def setup + Log4r::Logger.new("Mauve").outputters = Log4r::Outputter.stdout + 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 + assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) } + 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 |