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

49 lines
1.3 KiB
Ruby
Raw Normal View History

Shindo.tests("Fog::Compute[:digitalocean] | server model", ['digitalocean', 'compute']) do
service = Fog::Compute[:digitalocean]
server = service.servers.create :name => 'fog-test',
:image_id => service.images.first.id,
:region_id => service.regions.first.id,
:flavor_id => service.flavors.first.id
tests('The server model should') do
# Wait for the server to come up
begin
server.wait_for(120) { server.reload rescue nil; server.ready? }
rescue Fog::Errors::TimeoutError
# Server bootstrap took more than 120 secs!
end
tests('have the action') do
test('reload') { server.respond_to? 'reload' }
%w{
shutdown
reboot
}.each do |action|
test(action) { server.respond_to? action }
end
end
tests('have attributes') do
model_attribute_hash = server.attributes
attributes = [
:id,
:name,
:status,
:backups_active,
:flavor_id,
:region_id,
:image_id
]
tests("The server model should respond to") do
attributes.each do |attribute|
test("#{attribute}") { server.respond_to? attribute }
end
end
end
end
server.destroy
end