0
@@ -2,7 +2,19 @@ require File.dirname(__FILE__) + '/helper'
0
class TestTask < Test::Unit::TestCase
0
+ God::Socket.stubs(:new).returns(true)
0
+ @watch = God.watches['foo']
0
@task.valid_states = [:foo, :bar]
0
@@ -92,4 +104,171 @@ class TestTask < Test::Unit::TestCase
0
@task.driver.expects(:message).with(:action, [:foo, nil])
0
@task.action(:foo, nil)
0
+ def test_attach_should_schedule_for_poll_condition
0
+ c = Conditions::FakePollCondition.new
0
+ @task.driver.expects(:schedule).with(c, 0)
0
+ def test_attach_should_regsiter_for_event_condition
0
+ c = Conditions::FakeEventCondition.new
0
+ def test_detach_should_reset_poll_condition
0
+ c = Conditions::FakePollCondition.new
0
+ c.expects(:deregister).never
0
+ def test_detach_should_deregister_event_conditions
0
+ c = Conditions::FakeEventCondition.new
0
+ c.expects(:deregister).once
0
+ def test_trigger_should_send_message_to_driver
0
+ c = Conditions::FakePollCondition.new
0
+ @task.driver.expects(:message).with(:handle_event, [c])
0
+ def test_handle_poll_no_change_should_reschedule
0
+ c = Conditions::FakePollCondition.new
0
+ m = Metric.new(@task, {true => :up})
0
+ @task.directory[c] = m
0
+ c.expects(:test).returns(false)
0
+ @task.driver.expects(:schedule)
0
+ def test_handle_poll_change_should_move
0
+ c = Conditions::FakePollCondition.new
0
+ m = Metric.new(@task, {true => :up})
0
+ @task.directory[c] = m
0
+ c.expects(:test).returns(true)
0
+ @task.expects(:move).with(:up)
0
+ def test_handle_poll_should_use_overridden_transition
0
+ c = Conditions::Tries.new
0
+ m = Metric.new(@task, {true => :up})
0
+ @task.directory[c] = m
0
+ @task.expects(:move).with(:start)
0
+ def test_handle_poll_should_notify_if_triggering
0
+ c = Conditions::FakePollCondition.new
0
+ m = Metric.new(@task, {true => :up})
0
+ @task.directory[c] = m
0
+ c.expects(:test).returns(true)
0
+ @task.expects(:notify)
0
+ def test_handle_poll_should_not_notify_if_not_triggering
0
+ c = Conditions::FakePollCondition.new
0
+ m = Metric.new(@task, {true => :up})
0
+ @task.directory[c] = m
0
+ c.expects(:test).returns(false)
0
+ @task.expects(:notify).never
0
+ def test_handle_event_should_move
0
+ c = Conditions::FakeEventCondition.new
0
+ m = Metric.new(@task, {true => :up})
0
+ @task.directory[c] = m
0
+ @task.expects(:move).with(:up)
0
+ def test_handle_event_should_notify_if_triggering
0
+ c = Conditions::FakeEventCondition.new
0
+ m = Metric.new(@task, {true => :up})
0
+ @task.directory[c] = m
0
+ @task.expects(:notify)
0
+ def test_handle_event_should_not_notify_if_no_notify_set
0
+ c = Conditions::FakeEventCondition.new
0
+ m = Metric.new(@task, {true => :up})
0
+ @task.directory[c] = m
0
+ @task.expects(:notify).never
0
\ No newline at end of file
Comments
No one has commented yet.