mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(POOLER-73) Add spec tests for _check_disk_queue
Add spec tests for _check_disk_queue
This commit is contained in:
parent
25ad5d58f7
commit
3083186241
1 changed files with 39 additions and 0 deletions
|
|
@ -1021,6 +1021,45 @@ EOT
|
|||
end
|
||||
end
|
||||
|
||||
describe '#_check_disk_queue' do
|
||||
let(:vsphere) { double('vsphere') }
|
||||
|
||||
before do
|
||||
expect(subject).not_to be_nil
|
||||
end
|
||||
|
||||
context 'when no VMs in the queue' do
|
||||
it 'should not call create_vm_disk' do
|
||||
expect(subject).to receive(:create_vm_disk).exactly(0).times
|
||||
subject._check_disk_queue(vsphere)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when multiple VMs in the queue' do
|
||||
before(:each) do
|
||||
disk_task_vm('vm1',1)
|
||||
disk_task_vm('vm2',2)
|
||||
disk_task_vm('vm3',3)
|
||||
end
|
||||
|
||||
it 'should call create_vm_disk once' do
|
||||
expect(subject).to receive(:create_vm_disk).exactly(1).times
|
||||
subject._check_disk_queue(vsphere)
|
||||
end
|
||||
|
||||
it 'should snapshot the first VM in the queue' do
|
||||
expect(subject).to receive(:create_vm_disk).with('vm1','1',vsphere)
|
||||
subject._check_disk_queue(vsphere)
|
||||
end
|
||||
|
||||
it 'should log an error if one occurs' do
|
||||
expect(subject).to receive(:create_vm_disk).and_raise(RuntimeError,'MockError')
|
||||
expect(logger).to receive(:log).with('s', "[!] [disk_manager] disk creation appears to have failed")
|
||||
subject._check_disk_queue(vsphere)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#check_snapshot_queue' do
|
||||
let(:threads) {[]}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue