Sha256: c370e4877cb7087539d5ec55fd8b522eb9cc6c7191cf6ef3a563cf6ddad119b6

Contents?: true

Size: 777 Bytes

Versions: 10

Compression:

Stored size: 777 Bytes

Contents

require "#{File.dirname(__FILE__)}/../../test_helper"

class MonitorTest < Test::Unit::TestCase
  
  def setup
    @mon = PoolParty::Monitor.new(:cpu) do |c|
      vote_for(:expand) if c > 0.8
      configure if c < 0.1
    end
  end
  
  def test_monitor_initialize    
    assert_equal @mon.name, :cpu
    assert_equal Proc, @mon.monitor_block.class
  end
  
  def test_monitor_run_and_method_rettrieval    
    assert_equal({:vote_for => [:expand]}, @mon.run(0.9))
    assert_equal({}, @mon.run(0.3))
    assert_equal({:configure => []}, @mon.run(0.04))
  end
  
  def test_should_explode_if_no_block_is_given
    PoolParty::PoolPartyError.create("MonitorDefinitionError")
    assert_raises MonitorDefinitionError do
      PoolParty::Monitor.new :memory
    end
  end
  
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 test/lib/poolparty/monitor_test.rb
auser-poolparty-1.3.1 test/lib/poolparty/monitor_test.rb
auser-poolparty-1.3.2 test/lib/poolparty/monitor_test.rb
auser-poolparty-1.3.3 test/lib/poolparty/monitor_test.rb
auser-poolparty-1.3.4 test/lib/poolparty/monitor_test.rb
auser-poolparty-1.3.5 test/lib/poolparty/monitor_test.rb
fairchild-poolparty-1.3.5 test/lib/poolparty/monitor_test.rb
poolparty-1.3.4 test/lib/poolparty/monitor_test.rb
poolparty-1.3.3 test/lib/poolparty/monitor_test.rb
poolparty-1.3.1 test/lib/poolparty/monitor_test.rb