1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/joyent/requests/compute/machines_tests.rb

67 lines
1.6 KiB
Ruby

Shindo.tests("Fog::Compute[:joyent] | machine requests", ["joyent"]) do
@machine_format = {
"id" => String,
"name" => String,
"type" => String,
"state" => String,
"dataset" => String,
"memory" => Integer,
"disk" => Integer,
"ips" => Array,
"metadata" => Hash,
"created" => Time,
"updated" => Time
}
if Fog.mock?
@machines = Fog::Compute[:joyent].data[:machines] = {
"15080eca-3786-4bb8-a4d0-f43e1981cd72" => {
"id" => "15080eca-3786-4bb8-a4d0-f43e1981cd72",
"name" => "getting-started",
"type" => "smartmachine",
"state" => "running",
"dataset" => "sdc:sdc:smartos:1.3.15",
"memory" => 256,
"disk" => 5120,
"ips" => ["10.88.88.50"],
"metadata" => {},
"created" => Time.parse("2011-06-03T00:02:31+00:00"),
"updated" => Time.parse("2011-06-03T00:02:31+00:00")
}
}
end
@provider = Fog::Compute[:joyent]
#
# https://us-west-1.api.joyentcloud.com/docs#ListMachines
#
tests("#list_machines") do
if Fog.mock?
returns(@machines.length, "correct number of machines") do
@provider.list_machines.body.length
end
end
returns(Array, "returns an Array of machines") do
@provider.list_machines.body.class
end
formats([@machine_format]) do
@provider.list_machines.body
end
end
# https://us-west-1.api.joyentcloud.com/docs#GetMachine
tests("#get_machine") do
machines = @provider.list_machines.body
unless machines.empty?
formats(@machine_format) do
id = machines.first["id"]
@provider.get_machine(id).body
end
end
end
end