aboutsummaryrefslogtreecommitdiff
path: root/test/tc_mauve_alert_group.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-22 16:55:54 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-22 16:55:54 +0100
commit25b32914b72a5f709eca773f3511cc89c2e710c2 (patch)
tree4dab9e78e4c6b49220a837b38d463328c05e2983 /test/tc_mauve_alert_group.rb
parent3185e5d746abda1b7f42ecdbd74ec14359fda3bc (diff)
parentfd23821950f0562a8995735105cd31fdc6d55933 (diff)
merge
Diffstat (limited to 'test/tc_mauve_alert_group.rb')
-rw-r--r--test/tc_mauve_alert_group.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/tc_mauve_alert_group.rb b/test/tc_mauve_alert_group.rb
new file mode 100644
index 0000000..12f25ef
--- /dev/null
+++ b/test/tc_mauve_alert_group.rb
@@ -0,0 +1,47 @@
+$:.unshift "../lib"
+
+require 'test/unit'
+require 'mauve/alert_group'
+require 'th_mauve_resolv'
+require 'pp'
+
+class TcMauveAlert < Test::Unit::TestCase
+
+ def test_matches_alert
+
+ alert = Mauve::Alert.new
+
+ alert_group = Mauve::AlertGroup.new("test")
+
+ alert_group.includes = Proc.new { true }
+ assert( alert_group.matches_alert?(alert) )
+
+ alert_group.includes = Proc.new { false }
+ assert( !alert_group.matches_alert?(alert) )
+
+ alert_group.includes = Proc.new { summary =~ /Free swap/ }
+ alert.summary = "Free swap memory (mem_swap) too low"
+ assert( alert_group.matches_alert?(alert) )
+ alert.summary = "Free memory (mem_swap) too low"
+ assert( ! alert_group.matches_alert?(alert) )
+
+ alert_group.includes = Proc.new{ source == 'supportbot' }
+ alert.source = "supportbot"
+ assert( alert_group.matches_alert?(alert) )
+ alert.source = "support!"
+ assert( ! alert_group.matches_alert?(alert) )
+
+ alert_group.includes = Proc.new{ /raid/i.match(summary) }
+ alert.summary = "RAID failure"
+ assert( alert_group.matches_alert?(alert) )
+ alert.summary = "Disc failure"
+ assert( ! alert_group.matches_alert?(alert) )
+ end
+
+
+
+end
+
+
+
+