aboutsummaryrefslogtreecommitdiff
path: root/test/tc_mauve_configuration_builders_server.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/tc_mauve_configuration_builders_server.rb')
-rw-r--r--test/tc_mauve_configuration_builders_server.rb143
1 files changed, 143 insertions, 0 deletions
diff --git a/test/tc_mauve_configuration_builders_server.rb b/test/tc_mauve_configuration_builders_server.rb
new file mode 100644
index 0000000..4330610
--- /dev/null
+++ b/test/tc_mauve_configuration_builders_server.rb
@@ -0,0 +1,143 @@
+$:.unshift "../lib/"
+
+require 'test/unit'
+require 'mauve/configuration_builders/server'
+
+class TcMauveConfigurationBuildersServer < Test::Unit::TestCase
+
+ def test_server_params
+ hostname = "test.example.com"
+ database = "sqlite://./test.db"
+ initial_sleep = 314
+
+ config=<<EOF
+server {
+ hostname "#{hostname}"
+ database "#{database}"
+ initial_sleep #{initial_sleep}
+}
+EOF
+
+ assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) }
+
+ #
+ # Check that we've got the correct things set
+ #
+ s = Mauve::Server.instance
+ assert_equal(hostname, s.hostname)
+ assert_equal(database, s.database)
+ assert_equal(initial_sleep, s.initial_sleep)
+ end
+
+ def test_heartbeat_params
+ destination = "test-backup.example.com"
+ summary = "Mauve blurgh!"
+ detail = "<p>A very interesting test.</p>"
+ raise_after = 1000
+ send_every = 60
+
+ config=<<EOF
+server {
+ heartbeat {
+ destination "#{destination}"
+ summary "#{summary}"
+ detail "#{detail}"
+ raise_after #{raise_after}
+ send_every #{send_every}
+ }
+}
+EOF
+ assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) }
+
+ h = Mauve::Heartbeat.instance
+ assert_equal(detail, h.detail)
+ assert_equal(summary, h.summary)
+ assert_equal(destination, h.destination)
+ assert_equal(raise_after, h.raise_at)
+ assert_equal(send_every, h.sleep_interval)
+ end
+
+ def test_web_interface_params
+ ip = "::"
+ port = 12341
+ document_root = "./"
+ base_url = "http://www.example.com"
+ session_secret = "asd2342"
+ sleep_interval = 32
+
+ config=<<EOF
+server {
+ web_interface {
+ ip "#{ip}"
+ port #{port}
+ document_root "#{document_root}"
+ base_url "#{base_url}"
+ session_secret "#{session_secret}"
+ }
+}
+EOF
+ assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) }
+
+ assert_equal(ip, Mauve::HTTPServer.instance.ip)
+ assert_equal(port, Mauve::HTTPServer.instance.port)
+ assert_equal(document_root, Mauve::HTTPServer.instance.document_root)
+ assert_equal(base_url, Mauve::HTTPServer.instance.base_url)
+ assert_equal(session_secret, Mauve::HTTPServer.instance.session_secret)
+ end
+
+ def test_listener_params
+ ip = "::"
+ port = 12341
+ sleep_interval = 5678
+ config=<<EOF
+server {
+ listener {
+ ip "#{ip}"
+ port #{port}
+ sleep_interval #{sleep_interval}
+ }
+}
+EOF
+
+ assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) }
+ u = Mauve::UDPServer.instance
+ assert_equal(sleep_interval, u.sleep_interval)
+ assert_equal(IPAddr.new(ip), u.ip)
+ assert_equal(port, u.port)
+ end
+
+ def test_notifier_params
+ sleep_interval = 23
+ config=<<EOF
+server {
+ notifier {
+ sleep_interval #{sleep_interval}
+ }
+}
+EOF
+
+ assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) }
+ n = Mauve::Notifier.instance
+ assert_equal(sleep_interval, n.sleep_interval)
+ end
+
+ def test_processor_params
+ transmission_cache_expire_time = 3120
+ sleep_interval = 1235
+
+ config=<<EOF
+server {
+ processor {
+ transmission_cache_expire_time #{transmission_cache_expire_time}
+ sleep_interval #{sleep_interval}
+ }
+}
+EOF
+
+ assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) }
+ pr = Mauve::Processor.instance
+ assert_equal(transmission_cache_expire_time, pr.transmission_cache_expire_time)
+ assert_equal(sleep_interval, pr.sleep_interval)
+ end
+
+end