1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[cloudstack] added unit tests

This commit is contained in:
Brian Dorry 2011-10-10 00:37:26 -04:00
parent 0a0148399b
commit a5e9a57416
8 changed files with 277 additions and 0 deletions

View file

@ -65,6 +65,9 @@ An alternate file may be used by placing its path in the FOG_RC environment vari
:dnsimple_password:
:dnsmadeeasy_api_key:
:dnsmadeeasy_secret_key:
:cloudstack_host:
:cloudstack_api_key:
:cloudstack_secret_access_key:
#
# End of Fog Credentials File
#######################################################

View file

@ -0,0 +1,12 @@
# encoding: utf-8
Shindo.tests('Cloudstack | escape', ['cloudstack']) do
returns( Fog::Cloudstack.escape( "'Stöp!' said Fred_-~." ) ) { "%27St%C3%B6p%21%27%20said%20Fred_-%7E." }
end
Shindo.tests('Cloudstack | signed_params', ['cloudstack']) do
returns( Fog::Cloudstack.signed_params( 'abcdefg', 'account' => 'Lorem Ipsum', 'domainid' => 42, 'q' => 'keywords' ) ) { "V2CxRU4zQQtox1DZsH/66GDdzhg=" }
returns( Fog::Cloudstack.signed_params( 'abcdefg', 'account' => 'Lorem Ipsum', 'domainid' => '42', 'q' => 'keywords' ) ) { "V2CxRU4zQQtox1DZsH/66GDdzhg=" }
returns( Fog::Cloudstack.signed_params( 'abcdefg', 'account' => 'Lorem Ipsum', 'domainid' => 42, 'q' => nil ) ) { "5bsDirm5pPgVoreQ6vquKRN+4HI=" }
returns( Fog::Cloudstack.signed_params( 'abcdefg', 'account' => 'Lorem Ipsum', 'domainid' => 42, 'q' => '' ) ) { "5bsDirm5pPgVoreQ6vquKRN+4HI=" }
end

View file

@ -0,0 +1,26 @@
Shindo.tests('Fog::Compute[:cloudstack] | domain requests', ['cloudstack']) do
@domains_format = {
'listdomainsresponse' => {
'count' => Integer,
'domain' => [
'id' => Integer,
'name' => String,
'level' => Integer,
'haschild' => Fog::Boolean,
'parentdomainid' => Fog::Nullable::Integer,
'parentdomainname' => Fog::Nullable::String
]
}
}
tests('success') do
tests('#list_domains').formats(@domains_format) do
pending if Fog.mocking?
Fog::Compute[:cloudstack].list_domains
end
end
end

View file

@ -0,0 +1,32 @@
Shindo.tests('Fog::Compute[:cloudstack] | snapshot requests', ['cloudstack']) do
@snapshots_format = {
'listsnapshotsresponse' => {
'count' => Integer,
'snapshot' => [
'id' => Integer,
'account' => String,
'domainid' => Integer,
'domain' => String,
'snapshottype' => String,
'volumeid' => Integer,
'volumename' => String,
'volumetype' => String,
'created' => String,
'name' => String,
'intervaltype' => String,
'state' => String
]
}
}
tests('success') do
tests('#list_snapshots').formats(@snapshots_format) do
pending if Fog.mocking?
Fog::Compute[:cloudstack].list_snapshots
end
end
end

View file

@ -0,0 +1,53 @@
Shindo.tests('Fog::Compute[:cloudstack] | template requests', ['cloudstack']) do
@templates_format = {
'listtemplatesresponse' => {
'count' => Integer,
'template' => [
'id' => Integer,
'name' => String,
'displaytext' => String,
'ispublic' => Fog::Boolean,
'created' => String,
'isready' => Fog::Boolean,
'passwordenabled' => Fog::Boolean,
'format' => String,
'isfeatured' => Fog::Boolean,
'crossZones' => Fog::Boolean,
'ostypeid' => Integer,
'ostypename' => String,
'account' => String,
'zoneid' => Integer,
'zonename' => String,
'status' => String,
'size' => Integer,
'templatetype' => String,
'hypervisor' => String,
'domain' => String,
'domainid' => Integer,
'isextractable' => Fog::Boolean,
'checksum' => Fog::Nullable::String,
'sourcetemplateid' => Fog::Nullable::Integer,
'accountid' => Fog::Nullable::Integer,
'bootable' => Fog::Nullable::Boolean,
'hostid' => Fog::Nullable::Integer,
'hostname' => Fog::Nullable::String,
'jobid' => Fog::Nullable::Integer,
'jobstatus' => Fog::Nullable::Integer,
'removed' => Fog::Nullable::Boolean,
'templatetag' => Fog::Nullable::String,
'templatetype' => Fog::Nullable::String
]
}
}
tests('success') do
tests('#list_templates').formats(@templates_format) do
pending if Fog.mocking?
Fog::Compute[:cloudstack].list_templates('templateFilter' => "executable")
end
end
end

View file

@ -0,0 +1,71 @@
Shindo.tests('Fog::Compute[:cloudstack] | virtual machine requests', ['cloudstack']) do
@virtual_machines_format = {
'listvirtualmachinesresponse' => {
'count' => Integer,
'virtualmachine' => [
'id' => Integer,
'name' => String,
'displayname' => String,
'account' => String,
'domainid' => Integer,
'domain' => String,
'created' => String,
'state' => String,
'haenable' => Fog::Boolean,
'zoneid' => Integer,
'zonename' => String,
'hostid' => Integer,
'hostname' => Fog::Nullable::String,
'templateid' => Integer,
'templatename' => String,
'templatedisplaytext' => String,
'passwordenabled' => Fog::Boolean,
'serviceofferingid' => Integer,
'serviceofferingname' => String,
'cpunumber' => Integer,
'cpuspeed' => Integer,
'networkkbsread' => Fog::Nullable::Integer,
'memory' => Integer,
'cpuused' => Fog::Nullable::String,
'guestosid' => Integer,
'networkkbswrite' => Fog::Nullable::Integer,
'rootdeviceid' => Integer,
'rootdevicetype' => String,
'hypervisor' => String,
'group' => Fog::Nullable::String,
'groupid' => Fog::Nullable::Integer,
'isoname' => Fog::Nullable::String,
'isoid' => Fog::Nullable::Integer,
'securitygroup' => [
'id' => Integer,
'name' => Fog::Nullable::String,
'description' => Fog::Nullable::String
],
'nic' => [
'id' => Integer,
'networkid' => Integer,
'netmask' => String,
'gateway' => String,
'ipaddress' => String,
'traffictype' => String,
'type' => String,
'isdefault' => Fog::Boolean,
'macaddress' => String,
'broadcasturi' => Fog::Nullable::String,
'isolationuri' => Fog::Nullable::String
]
]
}
}
tests('success') do
tests('#list_virtual_machines').formats(@virtual_machines_format) do
pending if Fog.mocking?
Fog::Compute[:cloudstack].list_virtual_machines
end
end
end

View file

@ -0,0 +1,48 @@
Shindo.tests('Fog::Compute[:cloudstack] | volume requests', ['cloudstack']) do
@volumes_format = {
'listvolumesresponse' => {
'count' => Integer,
'volume' => [
'id' => Integer,
'name' => String,
'zoneid' => Integer,
'zonename' => String,
'type' => String,
'size' => Integer,
'created' => String,
'account' => String,
'domainid' => Integer,
'domain' => String,
'state' => String,
'storagetype' => String,
'hypervisor' => String,
'diskofferingid' => Fog::Nullable::Integer,
'diskofferingname' => Fog::Nullable::String,
'diskofferingdisplaytext' => Fog::Nullable::String,
'storage' => String,
'destroyed' => Fog::Boolean,
'isextractable' => Fog::Boolean,
'deviceid' => Fog::Nullable::Integer,
'virtualmachineid' => Fog::Nullable::Integer,
'vmname' => Fog::Nullable::String,
'vmdisplayname' => Fog::Nullable::String,
'vmstate' => Fog::Nullable::String,
'serviceofferingid' => Fog::Nullable::Integer,
'serviceofferingname' => Fog::Nullable::String,
'serviceofferingdisplaytext' => Fog::Nullable::String,
'attached' => Fog::Nullable::String
]
}
}
tests('success') do
tests('#list_volumes').formats(@volumes_format) do
pending if Fog.mocking?
Fog::Compute[:cloudstack].list_volumes('zoneid' => 1)
end
end
end

View file

@ -0,0 +1,32 @@
Shindo.tests('Fog::Compute[:cloudstack] | zone requests', ['cloudstack']) do
@zones_format = {
'listzonesresponse' => {
'count' => Integer,
'zone' => [
'id' => Integer,
'name' => String,
'dns1' => String,
'dns2' => String,
'internaldns1' => String,
'internaldns2' => String,
'vlan' => String,
'guestcidraddress' => String,
'networktype' => String,
'securitygroupsenabled' => [TrueClass,FalseClass],
'allocationstate' => String,
'dhcpprovider' => String
]
}
}
tests('success') do
tests('#list_zones').formats(@zones_format) do
pending if Fog.mocking?
Fog::Compute[:cloudstack].list_zones
end
end
end