Skip to content

Commit

Permalink
getScsiCandU may return either an empty hash or an array of controlle…
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu committed Apr 29, 2016
1 parent 691a22c commit 8d30c0f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Expand Up @@ -79,7 +79,7 @@ def add_disks(vim_obj, vmcs, disks)
controller_key, unit_number = vim_obj.send(:getScsiCandU)

# if there is no scsi controller
if controller_key.nil?
if controller_key.blank?
controller_key, unit_number = [-99, 0]
add_scsi_controller(vmcs, 0, controller_key)
end
Expand Down
Expand Up @@ -183,4 +183,26 @@
expect(subject).to eq('independent_nonpersistent')
end
end

context '#add_disks' do
let(:vim) { double("vim object") }
let(:vmcs) { double("VirtualMachineConfigSpec").as_null_object }
let(:disk) { {:disk_size_in_mb => 1024} }

it 'with valid controller key' do
allow(vim).to receive(:getScsiCandU).and_return([200, 1])

expect(vm).not_to receive(:add_scsi_controller)
expect(vm).to receive(:add_disk_config_spec).with(vmcs, disk).once
vm.add_disks(vim, vmcs, [disk])
end

it 'with no controller key' do
allow(vim).to receive(:getScsiCandU).and_return({})

expect(vm).to receive(:add_scsi_controller).with(vmcs, 0, -99).once
expect(vm).to receive(:add_disk_config_spec).with(vmcs, disk).once
vm.add_disks(vim, vmcs, [disk])
end
end
end

0 comments on commit 8d30c0f

Please sign in to comment.