Skip to content

Commit

Permalink
Test model and task changes
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Feb 15, 2018
1 parent 47306ed commit 3a8682e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/models/miq_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:VmReconfigureRequest => {:vm_reconfigure => "VM Reconfigure"},
:VmCloudReconfigureRequest => {:vm_cloud_reconfigure => "VM Cloud Reconfigure"},
:VmMigrateRequest => {:vm_migrate => "VM Migrate"},
:VmRetireRequest => {:vm_retire => "VM Retire"},
:AutomationRequest => {:automation => "Automation"},
:ServiceTemplateProvisionRequest => {:clone_to_service => "Service Provision"},
:ServiceReconfigureRequest => {:service_reconfigure => "Service Reconfigure"},
Expand Down
18 changes: 18 additions & 0 deletions spec/models/vm_retire_task_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe VmRetireTask do
describe '.do_request' do
let(:vm) { Vm.new }
before { subject.vm = vm }

it 'retires the vm and updates the status' do
expect(vm).to receive(:retire)
expect(subject).to receive(:update_and_notify_parent).with(hash_including(:state => 'retired'))
subject.do_request
end

it 'catches retire error and update the status' do
expect(vm).to receive(:retire).and_raise("Bad things happened")
expect(subject).to receive(:update_and_notify_parent).with(hash_including(:state => 'finished', :status => 'error', :message => 'Failed. Reason[Bad things happened]'))
subject.do_request
end
end
end

0 comments on commit 3a8682e

Please sign in to comment.