-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases for event state machines.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...ate/ManageIQ/System/Event/StateMachines/Refresh.class/__methods__/check_refreshed_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require_domain_file | ||
|
||
describe ManageIQ::Automate::System::Event::StateMachines::Refresh::CheckRefreshed do | ||
let(:event) { FactoryGirl.create(:event_stream) } | ||
let(:task) { FactoryGirl.create(:miq_task) } | ||
|
||
let(:svc_event) { MiqAeMethodService::MiqAeServiceEventStream.find(event.id) } | ||
let(:svc_task) { MiqAeMethodService::MiqAeServiceMiqTask.find(task.id) } | ||
|
||
let(:ae_service) do | ||
Spec::Support::MiqAeMockService.new(Spec::Support::MiqAeMockObject.new({})).tap do |service| | ||
current_object = Spec::Support::MiqAeMockObject.new | ||
current_object.parent = Spec::Support::MiqAeMockObject.new({}) | ||
service.object = current_object | ||
end | ||
end | ||
|
||
it 'when task is finished' do | ||
ae_service.set_state_var(:refresh_task_id, [task.id]) | ||
task.update_attributes(:state => 'Finished') | ||
described_class.new(ae_service).main | ||
expect(ae_service.root['ae_result']).to eq('ok') | ||
end | ||
|
||
it 'when task is active' do | ||
ae_service.set_state_var(:refresh_task_id, [task.id]) | ||
task.update_attributes(:state => 'Active') | ||
described_class.new(ae_service).main | ||
expect(ae_service.root['ae_result']).to eq('retry') | ||
expect(ae_service.root['ae_retry_interval']).to eq('1.minute') | ||
end | ||
|
||
it 'when task id is not set' do | ||
expect { described_class.new(ae_service).main }.to raise_error('Refresh task id is nil') | ||
end | ||
|
||
it 'when specified task does not exist' do | ||
ae_service.set_state_var(:refresh_task_id, [99]) | ||
expect { described_class.new(ae_service).main }.to raise_error('Refresh task with id: 99 not found') | ||
end | ||
end |