diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-10 16:09:08 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-10 16:09:08 +0100 |
commit | f1608b8098d0302f7e5c0e7989c78fa310d7d424 (patch) | |
tree | f4e1a9a9a5f6c0873bc568c96a21fbade7170104 /test | |
parent | a54a32084e9870af6f1ede97887c2332c21e812c (diff) |
Removed MauveTime. Added more tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/tc_mauve_notification.rb | 83 |
1 files changed, 78 insertions, 5 deletions
diff --git a/test/tc_mauve_notification.rb b/test/tc_mauve_notification.rb index 3414292..03e6b96 100644 --- a/test/tc_mauve_notification.rb +++ b/test/tc_mauve_notification.rb @@ -5,8 +5,11 @@ require 'mauve/alert' require 'mauve/notification' require 'mauve/configuration' require 'mauve/configuration_builder' +require 'mauve/configuration_builders' require 'mauve/mauve_time' require 'th_mauve_resolv' +require 'th_mauve_time' +require 'th_logger' require 'pp' @@ -53,7 +56,7 @@ class TcMauveDuringRunner < Test::Unit::TestCase # # This should give us midnight last sunday night. # - now = Mauve::MauveTime.now + now = Time.now midnight_sunday = now - (now.hour.hours + now.min.minutes + now.sec.seconds + now.wday.days) # @@ -101,11 +104,81 @@ end class TcMauveNotification < Test::Unit::TestCase def test_notify - end + t = Time.now + + config=<<EOF + +server { + database "sqlite::memory:" +} + +person ("test1") { + all { true } +} + +person ("test2") { + all { true } +} + +person ("test3") { + all { true } +} + +people_list "testers", %w( + test1 + test2 +) + +alert_group("default") { + level URGENT + + notify("test1") { + every 10.minutes + } + + notify("test1") { + every 15.minutes + } + + notify("test2") { + during { @test_time.to_i >= #{(t + 1.hour).to_i} } + every 10.minutes + } + + notify("test3") { + during { unacknowledged( 2.hours ) } + every 10.minutes + } + +} +EOF - def remind_at_next + + assert_nothing_raised { + Mauve::Configuration.current = Mauve::ConfigurationBuilder.parse(config) + Mauve::Server.instance.setup + alert = Mauve::Alert.new( + :alert_id => "test", + :source => "test", + :subject => "test" + ) + alert.raise! + } + + assert_equal(1, Mauve::Alert.count) + + reminder_times = { + "test1" => t + 10.minutes, + "test2" => t + 1.hour, + "test3" => t + 2.hours + } + + Mauve::AlertChanged.all.each do |a| + pp a + assert_equal("urgent", a.level, "Level is wrong") + assert_equal("raised", a.update_type, "Update type is wrong") + assert_in_delta(reminder_times[a.person].to_f, a.remind_at.to_time.to_f, 10.0, "reminder time is wrong for #{a.person}") + end end end - - |