Skip to content

Commit

Permalink
Add specs for MiqProvisionRedhat#poll_destination_powered_on_in_provider
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunne committed Jun 26, 2015
1 parent a8b2578 commit e60987d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions vmdb/spec/models/miq_provision_redhat/state_machine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,31 @@

@task.poll_destination_powered_off_in_provider
end

context "#poll_destination_powered_on_in_provider" do
it "requeues if the VM didn't start" do
VmRedhat.any_instance.stub(:with_provider_object => {:state => "down"})
expect(@task).to receive(:requeue_phase)

@task.poll_destination_powered_on_in_provider

expect(@task.phase_context[:power_on_wait_count]).to eq(1)
end

it "moves on if the vm started" do
VmRedhat.any_instance.stub(:with_provider_object => {:state => "up"})
expect(@task).to receive(:poll_destination_powered_off_in_provider)

@task.poll_destination_powered_on_in_provider

expect(@task.phase_context[:power_on_wait_count]).to be_nil
end

it "raises if the vm failed to start" do
@task.phase_context[:power_on_wait_count] = 121

expect { @task.poll_destination_powered_on_in_provider }.to raise_error(MiqException::MiqProvisionError)
end
end
end
end

0 comments on commit e60987d

Please sign in to comment.