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

60 lines
1.5 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
}
@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")
}
}
@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
formats(@machine_format) do
id = @provider.list_machines.body.first["id"]
@provider.get_machine(id)
end
end
end