Sha256: 3a8ca02401b3a24a9505b4323ccc516013adebb8c87b72958a96e99956e78b87

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path('../../common', __FILE__)
require File.expand_path('../../../lib/rrd-grapher/notifier/alarm_trigger', __FILE__)

describe 'AlarmTrigger' do
  it 'can can parse initialize parameters' do
    RRDNotifier::AlarmTrigger.load_param("*").should == nil
    RRDNotifier::AlarmTrigger.load_param("memory").should == "memory"
    RRDNotifier::AlarmTrigger.load_param("memory/*").should == ["memory", nil]
    RRDNotifier::AlarmTrigger.load_param("*/*").should == [nil, nil]
    RRDNotifier::AlarmTrigger.load_param("*/memory").should == [nil, "memory"]
  end
  
  it 'can handle packets with multiple counters' do
    manager = stub('manager', :active_alarm? => nil)
    trigger = RRDNotifier::AlarmTrigger.new(manager, "*", "*/*", "*/*", :max => 10, :index => 1)
    
    # we are not testing matching code, bypass
    trigger.expects(:match?).returns(true)
    p = Factory(:data_point, :values => [1, 45, 5])
    
    manager.expects(:raise_alarm).with(p.measure_id, kind_of(RRDNotifier::Alarm))
    trigger.check_alarms(p)
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rrd-grapher-1.0.3 spec/unit/alarm_trigger_spec.rb
rrd-grapher-1.0.2 spec/unit/alarm_trigger_spec.rb
rrd-grapher-1.0.1 spec/unit/alarm_trigger_spec.rb
rrd-grapher-1.0.0 spec/unit/alarm_trigger_spec.rb