mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fix linked clone mocked test unhandled exception
Without this patch, the test for the vSphere linked clone option to the vm_clone request throws an exception. For the full exception please see GH-697 discussion comments on Github at [1] This patch fixes the issue by removing the cleanup code which is not necessary for a Mocked test. The cleanup code was calling a method on the response_linked object which is not actually in scope. [1] https://github.com/fog/fog/pull/697
This commit is contained in:
parent
a318c9a239
commit
67cede19a5
2 changed files with 11 additions and 11 deletions
|
@ -5,7 +5,11 @@ module Fog
|
|||
module Shared
|
||||
private
|
||||
def vm_clone_check_options(options)
|
||||
options = { 'force' => false }.merge(options)
|
||||
default_options = {
|
||||
'force' => false,
|
||||
'linked_clone' => false,
|
||||
}
|
||||
options = default_options.merge(options)
|
||||
required_options = %w{ path name }
|
||||
required_options.each do |param|
|
||||
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.has_key? param
|
||||
|
|
|
@ -13,20 +13,16 @@ Shindo.tests("Fog::Compute[:vsphere] | vm_clone request", 'vsphere') do
|
|||
test("have a #{key} key") { response.has_key? key }
|
||||
end
|
||||
end
|
||||
template = "/Datacenters/Solutions/vm/Jeff/Templates/cloning_vm"
|
||||
|
||||
template = "/Datacenters/Solutions/vm/Jeff/Templates/centos56gm2"
|
||||
tests("Linked Clone | The return value should") do
|
||||
response_linked = compute.vm_clone('path' => template, 'name' => 'cloning_vm_linked', 'wait' => 1)
|
||||
test("be a kind of Hash") { response_linked.kind_of? Hash }
|
||||
response = compute.vm_clone('path' => template, 'name' => 'cloning_vm_linked', 'wait' => 1, 'linked_clone' => true)
|
||||
test("be a kind of Hash") { response.kind_of? Hash }
|
||||
%w{ vm_ref task_ref }.each do |key|
|
||||
test("have a #{key} key") { response_linked.has_key? key }
|
||||
test("have a #{key} key") { response.has_key? key }
|
||||
end
|
||||
end
|
||||
## clean up afterward as in the aws tests.
|
||||
compute.vm_power_off('uuid' => response_linked['vm_attributes']['uuid'], 'instance_uuid' => response_linked['vm_attributes']['instance_uuid'], 'force' => 1)
|
||||
compute.vm_destroy('instance_uuid' => response_linked['vm_attributes']['instance_uuid'])
|
||||
compute.vm_power_off('uuid' => response['vm_attributes']['uuid'], 'instance_uuid' => response['vm_attributes']['instance_uuid'], 'force' => 1)
|
||||
compute.vm_destroy('instance_uuid' => response['vm_attributes']['instance_uuid'])
|
||||
|
||||
|
||||
tests("When invalid input is presented") do
|
||||
raises(ArgumentError, 'it should raise ArgumentError') { compute.vm_clone(:foo => 1) }
|
||||
raises(Fog::Compute::Vsphere::NotFound, 'it should raise Fog::Compute::Vsphere::NotFound when the UUID is not a string') do
|
||||
|
|
Loading…
Reference in a new issue