mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Clusters lists tests
This commit is contained in:
parent
66e5521836
commit
abc39ec3bf
3 changed files with 68 additions and 1 deletions
|
|
@ -304,7 +304,44 @@ module Fog
|
|||
},
|
||||
:datacenters => {
|
||||
"Solutions" => {:name => "Solutions", :status => "grey"}
|
||||
}
|
||||
},
|
||||
:clusters =>
|
||||
[{:id => "1d4d9a3f-e4e8-4c40-b7fc-263850068fa4",
|
||||
:name => "Solutionscluster",
|
||||
:num_host => "4",
|
||||
:num_cpu_cores => "16",
|
||||
:overall_status => "green",
|
||||
:datacenter => "Solutions",
|
||||
:klass => "RbVmomi::VIM::ComputeResource"
|
||||
},
|
||||
{:id => "e4195973-102b-4096-bbd6-5429ff0b35c9",
|
||||
:name => "Problemscluster",
|
||||
:num_host => "4",
|
||||
:num_cpu_cores => "32",
|
||||
:overall_status => "green",
|
||||
:datacenter => "Solutions",
|
||||
:klass => "RbVmomi::VIM::ComputeResource"
|
||||
},
|
||||
{
|
||||
:klass => "RbVmomi::VIM::Folder",
|
||||
:clusters => [{:id => "03616b8d-b707-41fd-b3b5-The first",
|
||||
:name => "Problemscluster",
|
||||
:num_host => "4",
|
||||
:num_cpu_cores => "32",
|
||||
:overall_status => "green",
|
||||
:datacenter => "Solutions",
|
||||
:klass => "RbVmomi::VIM::ComputeResource"
|
||||
},
|
||||
{:id => "03616b8d-b707-41fd-b3b5-the Second",
|
||||
:name => "Lastcluster",
|
||||
:num_host => "8",
|
||||
:num_cpu_cores => "32",
|
||||
:overall_status => "green",
|
||||
:datacenter => "Solutions",
|
||||
:klass => "RbVmomi::VIM::ComputeResource"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,8 +38,27 @@ module Fog
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def list_clusters(filters = { })
|
||||
raw_clusters.map do |cluster|
|
||||
cluster
|
||||
end
|
||||
end
|
||||
|
||||
def raw_clusters
|
||||
folder = self.data[:clusters]
|
||||
@raw_clusters = get_raw_clusters_from_folder(folder)
|
||||
end
|
||||
|
||||
def get_raw_clusters_from_folder(folder)
|
||||
folder.map do |child|
|
||||
if child[:klass] == "RbVmomi::VIM::ComputeResource"
|
||||
child
|
||||
elsif child[:klass] == "RbVmomi::VIM::Folder"
|
||||
get_raw_clusters_from_folder(child[:clusters])
|
||||
end
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
11
tests/vsphere/requests/compute/list_clusters_tests.rb
Normal file
11
tests/vsphere/requests/compute/list_clusters_tests.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Shindo.tests('Fog::Compute[:vsphere] | list_clusters request', ['vsphere']) do
|
||||
tests("When listing all clusters") do
|
||||
|
||||
response = Fog::Compute[:vsphere].list_clusters
|
||||
test("Clusters extracted from folders... ") {response.length == 4}
|
||||
|
||||
tests("The response data format ...") do
|
||||
test("be a kind of Hash") { response.kind_of? Array }
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue