mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
(POOLER-73) Update find_folder in vsphere_helper.rb to enable testing
Previously, it was not able to mock objects to impersonate a RbVmomi::VIM::Folder object. This commit changes the case statement to an if statement using is_a? which can be mocked and allow mocked objects to mimic real objects.
This commit is contained in:
parent
42b7d2d222
commit
88052ac85a
1 changed files with 4 additions and 5 deletions
|
|
@ -178,8 +178,7 @@ module Vmpooler
|
||||||
base = datacenter.vmFolder
|
base = datacenter.vmFolder
|
||||||
folders = foldername.split('/')
|
folders = foldername.split('/')
|
||||||
folders.each do |folder|
|
folders.each do |folder|
|
||||||
case base
|
if base.is_a? RbVmomi::VIM::Folder
|
||||||
when RbVmomi::VIM::Folder
|
|
||||||
base = base.childEntity.find { |f| f.name == folder }
|
base = base.childEntity.find { |f| f.name == folder }
|
||||||
else
|
else
|
||||||
abort "Unexpected object type encountered (#{base.class}) while finding folder"
|
abort "Unexpected object type encountered (#{base.class}) while finding folder"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue