Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vm_migrate_task statemachine_task_status value. #38

Merged
merged 1 commit into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class MiqAeServiceVmMigrateTask < MiqAeServiceMiqRequestTask
def statemachine_task_status
ar_method do
if ['finished', 'migrated'].include?(@object.state)
'ok'
@object.status.to_s.downcase == 'error' ? 'error' : 'ok'
else
'retry'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,56 @@ def invoke_ae
end
end

context "vm_migrate_task.statemachine_task_status" do
let(:ae_svc_prov) { MiqAeMethodService::MiqAeServiceVmMigrateTask.find(miq_provision.id) }

shared_examples_for "#statemachine_task_status" do
it "runs successfully" do
expect(ae_svc_prov.statemachine_task_status).to eq(return_status)
end
end

context "returns ok for finished/ok" do
let(:return_status) { "ok" }
let(:miq_provision) do
FactoryGirl.create(:vm_migrate_task, :status => "Ok", :state => "finished")
end
it_behaves_like "#statemachine_task_status"
end

context "returns error for finished/error" do
let(:return_status) { "error" }
let(:miq_provision) do
FactoryGirl.create(:vm_migrate_task, :status => "Error", :state => "finished")
end
it_behaves_like "#statemachine_task_status"
end

context "returns ok for migrated/ok" do
let(:return_status) { "ok" }
let(:miq_provision) do
FactoryGirl.create(:vm_migrate_task, :status => "Ok", :state => "migrated")
end
it_behaves_like "#statemachine_task_status"
end

context "returns error for migrated/error" do
let(:return_status) { "error" }
let(:miq_provision) do
FactoryGirl.create(:vm_migrate_task, :status => "Error", :state => "migrated")
end
it_behaves_like "#statemachine_task_status"
end

context "returns retry for pending" do
let(:return_status) { "retry" }
let(:miq_provision) do
FactoryGirl.create(:vm_migrate_task, :state => "pending")
end
it_behaves_like "#statemachine_task_status"
end
end

context "subclassing" do
before do
method = "$evm.root['#{@ae_result_key}'] = $evm.root['miq_provision']"
Expand Down