Skip to content

Commit ff549fb

Browse files
committed
Add test for active_vm nil guard in update_detached_disks
1 parent 66f6142 commit ff549fb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/bosh-director/spec/unit/bosh/director/disk_manager_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,24 @@ module Bosh::Director
913913
end
914914
end
915915

916+
context 'when there is no active VM for the disk' do
917+
before do
918+
instance_model.active_vm.destroy
919+
instance_model.reload
920+
end
921+
922+
it 'logs a warning and skips the update' do
923+
expect(per_spec_logger).to receive(:warn).with(/No active VM for disk/)
924+
925+
disk_manager.update_detached_disks(instance_plan)
926+
927+
expect(cloud).to_not have_received(:update_disk)
928+
model = Models::PersistentDisk.where(disk_cid: 'disk123').first
929+
expect(model.size).to eq(2048)
930+
expect(model.cloud_properties).to eq({ 'old' => 'properties' })
931+
end
932+
end
933+
916934
context 'when disk has not changed' do
917935
# Both size and cloud_properties match the initial disk state — no change.
918936
let(:job_persistent_disk_size) { 2048 }

0 commit comments

Comments
 (0)