diff --git a/spec/configs/flapjack-notifier-couchdb.ini b/spec/configs/flapjack-notifier-couchdb.ini new file mode 100644 index 000000000..68373fe2a --- /dev/null +++ b/spec/configs/flapjack-notifier-couchdb.ini @@ -0,0 +1,25 @@ +# top level +[notifier] + notifier-directories = /usr/lib/flapjack/notifiers/ /path/to/my/notifiers + notifiers = mailer, xmpp + +[persistence] + backend = couchdb + host = localhost + port = 5984 + username = spoons + password = doom + +[transport] + backend = beanstalkd + basedir = /usr/lib/flapjack/persistence/ + host = localhost + port = 11300 + +[mailer-notifier] + from_address = foo@bar.com + +[xmpp-notifier] + jid = foo@bar.com + password = barfoo + diff --git a/spec/configs/flapjack-notifier.ini b/spec/configs/flapjack-notifier.ini new file mode 100644 index 000000000..e674040d1 --- /dev/null +++ b/spec/configs/flapjack-notifier.ini @@ -0,0 +1,25 @@ +# top level +[notifier] + notifier-directories = /usr/lib/flapjack/notifiers/ /path/to/my/notifiers + notifiers = mailer, xmpp + +# persistence layers +[persistence] + backend = datamapper + uri = sqlite3:///tmp/flapjack.db + +# message transports +[transport] + backend = beanstalkd + basedir = /usr/lib/flapjack/persistence/ + host = localhost + port = 11300 + +# notifiers +[mailer-notifier] + from_address = foo@bar.com + +[xmpp-notifier] + jid = foo@bar.com + password = barfoo + diff --git a/spec/configs/recipients.ini b/spec/configs/recipients.ini new file mode 100644 index 000000000..bf57ad450 --- /dev/null +++ b/spec/configs/recipients.ini @@ -0,0 +1,14 @@ +# recipients + +[John Doe] + email = johndoe@example.org + jid = john@example.org + phone = +61 400 111 222 + pager = 61400111222 + +[Jane Doe] + email = janedoe@example.org + jid = jane@example.org + phone = +61 222 333 111 + pager = 61222333111 + diff --git a/spec/notifier_options_multiplexer_spec.rb b/spec/notifier_options_multiplexer_spec.rb new file mode 100644 index 000000000..0fd130546 --- /dev/null +++ b/spec/notifier_options_multiplexer_spec.rb @@ -0,0 +1,51 @@ +require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'cli', 'notifier') + +describe "notifier options multiplexer" do + + before(:all) do + @config_filename = File.join(File.dirname(__FILE__), 'configs', 'flapjack-notifier.ini') + @recipients_filename = File.join(File.dirname(__FILE__), 'configs', 'recipients.ini') + + @couchdb_config_filename = File.join(File.dirname(__FILE__), 'configs', 'flapjack-notifier-couchdb.ini') + end + + it "should setup notifier options from specified config file" do + args = ["-c", @config_filename, "-r", @recipients_filename] + config = Flapjack::Notifier::Options.parse(args) + config.notifiers.each do |notifier| + %w(mailer xmpp).include?(notifier.keys.first) + end + + config.notifier_directories.each do |dir| + %w(/usr/lib/flapjack/notifiers/ /path/to/my/notifiers).include?(dir) + end + end + + it "should setup beanstalkd transport options from specified config file" do + args = ["-c", @config_filename, "-r", @recipients_filename] + config = Flapjack::Notifier::Options.parse(args) + config.transport.backend.should == "beanstalkd" + config.transport.host.should == "localhost" + config.transport.port.should == "11300" + end + + it "should setup datamapper persistence options from specified config file" do + args = ["-c", @config_filename, "-r", @recipients_filename] + config = Flapjack::Notifier::Options.parse(args) + config.persistence.backend.should == "datamapper" + config.persistence.uri.should == "sqlite3:///tmp/flapjack.db" + end + + it "should setup couchdb persistence backend from specified config file" do + args = [ "-c", @couchdb_config_filename, "-r", @recipients_filename ] + config = Flapjack::Notifier::Options.parse(args) + config.persistence.backend.should == "couchdb" + config.persistence.host.should == "localhost" + config.persistence.port.should == "5984" + config.persistence.username.should == "spoons" + config.persistence.password.should == "doom" + end + +end + +