mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
fixed up some issues with the tests, needs more work and thought
This commit is contained in:
parent
44e400db41
commit
e966e73ff0
4 changed files with 16 additions and 14 deletions
7
Rakefile
7
Rakefile
|
@ -52,10 +52,9 @@ require "tasks/test_task"
|
||||||
Fog::Rake::TestTask.new
|
Fog::Rake::TestTask.new
|
||||||
|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
task :dynect do
|
task :vsphere do
|
||||||
[false].each do |mock|
|
[true].each do |mock|
|
||||||
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/dns/requests/dynect")
|
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/vsphere")
|
||||||
#sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/dns/models/")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -123,8 +123,9 @@ module Fog
|
||||||
# This inline rescue catches any standard error. While a VM is
|
# This inline rescue catches any standard error. While a VM is
|
||||||
# cloning, a call to the macs method will throw and NoMethodError
|
# cloning, a call to the macs method will throw and NoMethodError
|
||||||
attrs['mac_addresses'] = vm_mob_ref.macs rescue nil
|
attrs['mac_addresses'] = vm_mob_ref.macs rescue nil
|
||||||
attrs['path'] = "/"+vm_mob_ref.parent.path.map(&:last).join('/')
|
# Rescue nil to catch testing while vm_mob_ref isn't reaL??
|
||||||
attrs['relative_path'] = (attrs['path'].split('/').reject {|e| e.empty?} - ["Datacenters", attrs['datacenter'], "vm"]).join("/")
|
attrs['path'] = "/"+vm_mob_ref.parent.path.map(&:last).join('/') rescue nil
|
||||||
|
attrs['relative_path'] = (attrs['path'].split('/').reject {|e| e.empty?} - ["Datacenters", attrs['datacenter'], "vm"]).join("/") rescue nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,10 @@ module Fog
|
||||||
required_options.each do |param|
|
required_options.each do |param|
|
||||||
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.has_key? param
|
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.has_key? param
|
||||||
end
|
end
|
||||||
raise ArgumentError, "#{options["datacenter"]} Doesn't Exist!" unless get_datacenter(options["datacenter"])
|
unless ENV['FOG_MOCK']
|
||||||
raise ArgumentError, "#{options["template_path"]} Doesn't Exist!" unless get_virtual_machine(options["template_path"], options["datacenter"])
|
raise ArgumentError, "#{options["datacenter"]} Doesn't Exist!" unless get_datacenter(options["datacenter"])
|
||||||
|
raise ArgumentError, "#{options["template_path"]} Doesn't Exist!" unless get_virtual_machine(options["template_path"], options["datacenter"])
|
||||||
|
end
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -256,11 +258,11 @@ module Fog
|
||||||
class Mock
|
class Mock
|
||||||
include Shared
|
include Shared
|
||||||
def vm_clone(options = {})
|
def vm_clone(options = {})
|
||||||
# Option handling
|
# Option handling TODO Needs better method of checking
|
||||||
options = vm_clone_check_options(options)
|
options = vm_clone_check_options(options)
|
||||||
notfound = lambda { raise Fog::Compute::Vsphere::NotFound, "Could not find VM template" }
|
notfound = lambda { raise Fog::Compute::Vsphere::NotFound, "Could not find VM template" }
|
||||||
list_virtual_machines.find(notfound) do |vm|
|
list_virtual_machines.find(notfound) do |vm|
|
||||||
vm[:name] == options['path'].split("/")[-1]
|
vm[:name] == options['template_path'].split("/")[-1]
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
'vm_ref' => 'vm-123',
|
'vm_ref' => 'vm-123',
|
||||||
|
|
|
@ -4,20 +4,20 @@ Shindo.tests("Fog::Compute[:vsphere] | vm_clone request", 'vsphere') do
|
||||||
response = nil
|
response = nil
|
||||||
response_linked = nil
|
response_linked = nil
|
||||||
|
|
||||||
template = "rhel64"
|
template = "folder/rhel64"
|
||||||
datacenter = "Solutions"
|
datacenter = "Solutions"
|
||||||
tests("Standard Clone | The return value should") do
|
tests("Standard Clone | The return value should") do
|
||||||
response = compute.vm_clone('template_path' => template, 'name' => 'cloning_vm', 'wait' => 1)
|
response = compute.vm_clone('datacenter' => datacenter, 'template_path' => template, 'name' => 'cloning_vm', 'wait' => true)
|
||||||
test("be a kind of Hash") { response.kind_of? Hash }
|
test("be a kind of Hash") { response.kind_of? Hash }
|
||||||
%w{ vm_ref task_ref }.each do |key|
|
%w{ vm_ref task_ref }.each do |key|
|
||||||
test("have a #{key} key") { response.has_key? key }
|
test("have a #{key} key") { response.has_key? key }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
template = "rhel64"
|
template = "folder/rhel64"
|
||||||
datacenter = "Solutions"
|
datacenter = "Solutions"
|
||||||
tests("Linked Clone | The return value should") do
|
tests("Linked Clone | The return value should") do
|
||||||
response = compute.vm_clone('template_path' => template, 'name' => 'cloning_vm_linked', 'wait' => 1, 'linked_clone' => true)
|
response = compute.vm_clone('datacenter' => datacenter, 'template_path' => template, 'name' => 'cloning_vm_linked', 'wait' => 1, 'linked_clone' => true)
|
||||||
test("be a kind of Hash") { response.kind_of? Hash }
|
test("be a kind of Hash") { response.kind_of? Hash }
|
||||||
%w{ vm_ref task_ref }.each do |key|
|
%w{ vm_ref task_ref }.each do |key|
|
||||||
test("have a #{key} key") { response.has_key? key }
|
test("have a #{key} key") { response.has_key? key }
|
||||||
|
|
Loading…
Reference in a new issue