aboutsummaryrefslogtreecommitdiff
path: root/test/tc_mauve_alert.rb
blob: ef8042404c601946061f5f4c54c3031a6e99a4b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$:.unshift "../lib"

require 'test/unit'
require 'mauve/alert'
require 'mauve/configuration'
require 'mauve/configuration_builder'
require 'th_mauve_resolv'
require 'pp' 

class TcMauveAlert < Test::Unit::TestCase 

  def test_source_list

    config=<<EOF
source_list "test", %w(test-1.example.com)

source_list "has_ipv4", "0.0.0.0/0"

source_list "has_ipv6", "2000::/3"
EOF

    Mauve::Configuration.current = Mauve::ConfigurationBuilder.parse(config)

    a = Mauve::Alert.new
    a.subject = "www.example.com"

    assert( a.in_source_list?("test")     )
    assert_equal( %w(test has_ipv4).sort, a.source_lists.sort )

    a.subject = "www2.example.com"
    assert( a.in_source_list?("has_ipv6") )
    assert_equal( %w(has_ipv6 has_ipv4).sort, a.source_lists.sort )
  end


  def test_summary

    a = Mauve::Alert.new
    a.summary = "Free swap memory (MB) (memory_swap) is too low"

    assert_match(/memory_swap/, a.summary)

  end


end