mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
converting shared model specs to tests
This commit is contained in:
parent
71915f6174
commit
ee4031c065
28 changed files with 136 additions and 312 deletions
|
@ -1,14 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/flavors_examples'
|
||||
|
||||
describe 'Fog::AWS::Compute::Flavors' do
|
||||
|
||||
it_should_behave_like "Flavors"
|
||||
|
||||
subject { @flavor = @flavors.all.first }
|
||||
|
||||
before(:each) do
|
||||
@flavors = AWS[:compute].flavors
|
||||
end
|
||||
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/servers_examples'
|
||||
|
||||
describe 'Fog::AWS::Compute::Servers' do
|
||||
|
||||
it_should_behave_like "Servers"
|
||||
|
||||
subject { @server = @servers.new(:image_id => GENTOO_AMI) }
|
||||
|
||||
before(:each) do
|
||||
@servers = AWS[:compute].servers
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/flavors_examples'
|
||||
|
||||
describe 'Fog::Bluebox::Compute::Flavors' do
|
||||
|
||||
if Fog.mocking?
|
||||
it "needs to have mocks implemented"
|
||||
else
|
||||
it_should_behave_like "Flavors"
|
||||
end
|
||||
subject { @flavor = @flavors.all.first }
|
||||
|
||||
before(:each) do
|
||||
@flavors = Bluebox[:compute].flavors
|
||||
end
|
||||
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/server_examples'
|
||||
|
||||
describe 'Fog::Bluebox::Compute::Server' do
|
||||
|
||||
if Fog.mocking?
|
||||
it "needs to have mocks implemented"
|
||||
else
|
||||
it_should_behave_like "Server"
|
||||
end
|
||||
|
||||
subject {
|
||||
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
||||
@image_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
|
||||
@server = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :password => "chunkybacon")
|
||||
}
|
||||
|
||||
before(:each) do
|
||||
@servers = Bluebox[:compute].servers
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/servers_examples'
|
||||
|
||||
describe 'Fog::Bluebox::Compute::Servers' do
|
||||
|
||||
if Fog.mocking?
|
||||
it "needs to have mocks implemented"
|
||||
else
|
||||
it_should_behave_like "Servers"
|
||||
end
|
||||
|
||||
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||
subject {
|
||||
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
||||
@image_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
|
||||
@server = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :password => "chunkybacon")
|
||||
@server
|
||||
}
|
||||
|
||||
before(:each) do
|
||||
@servers = Bluebox[:compute].servers
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/flavors_examples'
|
||||
|
||||
describe 'Fog::Rackspace::Compute::Flavors' do
|
||||
|
||||
if Fog.mocking?
|
||||
it "needs to have mocks implemented"
|
||||
else
|
||||
it_should_behave_like "Flavors"
|
||||
end
|
||||
|
||||
subject { @flavor = @flavors.all.first }
|
||||
|
||||
before(:each) do
|
||||
@flavors = Rackspace[:compute].flavors
|
||||
end
|
||||
|
||||
end
|
|
@ -1,55 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/server_examples'
|
||||
|
||||
describe 'Fog::Rackspace::Compute::Server' do
|
||||
|
||||
if Fog.mocking?
|
||||
it "needs to have mocks implemented"
|
||||
else
|
||||
it_should_behave_like "Server"
|
||||
end
|
||||
|
||||
# flavor 1 = 256, image 49 = Ubuntu 10.04 LTS (lucid)
|
||||
subject { @server = @servers.new(:flavor_id => 1, :image_id => 49, :name => "fog_#{Time.now.to_i}") }
|
||||
|
||||
before(:each) do
|
||||
@servers = Rackspace[:compute].servers
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#initialize" do
|
||||
|
||||
it "should remap attributes from parser" do
|
||||
server = @servers.new({
|
||||
'addresses' => 'addresses',
|
||||
'adminPass' => 'password',
|
||||
'flavorId' => 'flavor_id',
|
||||
'hostId' => 'host_id',
|
||||
'imageId' => 'image_id',
|
||||
'metadata' => 'metadata',
|
||||
'name' => 'name',
|
||||
'personality' => 'personality',
|
||||
'progress' => 'progress',
|
||||
'status' => 'status'
|
||||
})
|
||||
server.addresses.should == 'addresses'
|
||||
server.password.should == 'password'
|
||||
server.flavor_id.should == 'flavor_id'
|
||||
server.host_id.should == 'host_id'
|
||||
server.image_id.should == 'image_id'
|
||||
server.metadata.should == 'metadata'
|
||||
server.name.should == 'name'
|
||||
server.personality.should == 'personality'
|
||||
server.progress.should == 'progress'
|
||||
server.status.should == 'status'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/servers_examples'
|
||||
|
||||
describe 'Fog::Rackspace::Compute::Servers' do
|
||||
|
||||
it_should_behave_like "Servers"
|
||||
|
||||
# flavor 1 = 256, image 49 = Ubuntu 10.04 LTS (lucid)
|
||||
subject { @server = @servers.new(:flavor_id => 1, :image_id => 49, :name => "fog_#{Time.now.to_i}") }
|
||||
|
||||
before(:each) do
|
||||
@servers = Rackspace[:compute].servers
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/flavors_examples'
|
||||
|
||||
describe 'Fog::Slicehost::Compute::Flavors' do
|
||||
|
||||
if Fog.mocking?
|
||||
it "needs to have mocks implemented"
|
||||
else
|
||||
it_should_behave_like "Flavors"
|
||||
end
|
||||
|
||||
subject { @flavor = @flavors.all.first }
|
||||
|
||||
before(:each) do
|
||||
@flavors = Slicehost[:compute].flavors
|
||||
end
|
||||
|
||||
end
|
|
@ -1,55 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/server_examples'
|
||||
|
||||
describe 'Fog::Slicehost::Compute::Server' do
|
||||
|
||||
if Fog.mocking?
|
||||
it "needs to have mocks implemented"
|
||||
else
|
||||
it_should_behave_like "Server"
|
||||
end
|
||||
|
||||
# flavor 1 = 256, image 49 = Ubuntu 10.04 LTS (lucid)
|
||||
subject { @server = @servers.new(:flavor_id => 1, :image_id => 49, :name => Time.now.to_i.to_s) }
|
||||
|
||||
before(:each) do
|
||||
@servers = Slicehost[:compute].servers
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#initialize" do
|
||||
|
||||
it "should remap attributes from parser" do
|
||||
server = @servers.new({
|
||||
'addresses' => 'addresses',
|
||||
'backup-id' => 'backup_id',
|
||||
'bw-in' => 'bw_in',
|
||||
'bw-out' => 'bw_out',
|
||||
'flavor-id' => 'flavor_id',
|
||||
'image-id' => 'image_id',
|
||||
'name' => 'name',
|
||||
'root-password' => 'password',
|
||||
'progress' => 'progress',
|
||||
'status' => 'status'
|
||||
})
|
||||
server.addresses.should == 'addresses'
|
||||
server.backup_id.should == 'backup_id'
|
||||
server.bandwidth_in.should == 'bw_in'
|
||||
server.bandwidth_out.should == 'bw_out'
|
||||
server.flavor_id.should == 'flavor_id'
|
||||
server.image_id.should == 'image_id'
|
||||
server.name.should == 'name'
|
||||
server.password.should == 'password'
|
||||
server.progress.should == 'progress'
|
||||
server.status.should == 'status'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../shared_examples/servers_examples'
|
||||
|
||||
describe 'Fog::Slicehost::Compute::Servers' do
|
||||
|
||||
if Fog.mocking?
|
||||
it "needs to have mocks implemented"
|
||||
else
|
||||
it_should_behave_like "Servers"
|
||||
end
|
||||
|
||||
# flavor 1 = 256, image 49 = Ubuntu 10.04 LTS (lucid)
|
||||
subject { @server = @servers.new(:flavor_id => 1, :image_id => 49, :name => Time.now.to_i.to_s) }
|
||||
|
||||
before(:each) do
|
||||
@servers = Slicehost[:compute].servers
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
if @server && !@server.new_record?
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
5
tests/aws/models/compute/flavors_tests.rb
Normal file
5
tests/aws/models/compute/flavors_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('AWS::Compute | flavors collection', ['aws']) do
|
||||
|
||||
flavors_tests(AWS[:compute])
|
||||
|
||||
end
|
6
tests/aws/models/compute/server_tests.rb
Normal file
6
tests/aws/models/compute/server_tests.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Shindo.tests('AWS::Compute | server model', ['aws']) do
|
||||
|
||||
# image ami-1a837773 = Ubuntu
|
||||
server_tests(AWS[:compute], {:image_id => 'ami-1a837773'})
|
||||
|
||||
end
|
6
tests/aws/models/compute/servers_tests.rb
Normal file
6
tests/aws/models/compute/servers_tests.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Shindo.tests('AWS::Compute | servers collection', ['aws']) do
|
||||
|
||||
# image ami-1a837773 = Ubuntu
|
||||
servers_tests(AWS[:compute], {:image_id => 'ami-1a837773'})
|
||||
|
||||
end
|
5
tests/bluebox/models/compute/flavors_tests.rb
Normal file
5
tests/bluebox/models/compute/flavors_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('Bluebox::Compute | flavors collection', ['bluebox']) do
|
||||
|
||||
flavors_tests(Bluebox[:compute])
|
||||
|
||||
end
|
5
tests/bluebox/models/compute/server_tests.rb
Normal file
5
tests/bluebox/models/compute/server_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('Bluebox::Compute | server model', ['bluebox']) do
|
||||
|
||||
server_tests(Bluebox[:compute], {:image_id => 'a00baa8f-b5d0-4815-8238-b471c4c4bf72'})
|
||||
|
||||
end
|
6
tests/bluebox/models/compute/servers_tests.rb
Normal file
6
tests/bluebox/models/compute/servers_tests.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Shindo.tests('Bluebox::Compute | servers collection', ['bluebox']) do
|
||||
|
||||
# Ubuntu 9.10 64bit
|
||||
servers_tests(Bluebox[:compute], {:image_id => 'a00baa8f-b5d0-4815-8238-b471c4c4bf72'})
|
||||
|
||||
end
|
|
@ -11,6 +11,10 @@ $LOAD_PATH.unshift __DIR__ unless
|
|||
require 'tests/helpers/collection_tests'
|
||||
require 'tests/helpers/model_tests'
|
||||
|
||||
require 'tests/helpers/compute/flavors_tests'
|
||||
require 'tests/helpers/compute/server_tests'
|
||||
require 'tests/helpers/compute/servers_tests'
|
||||
|
||||
require 'tests/helpers/storage/directory_tests'
|
||||
require 'tests/helpers/storage/directories_tests'
|
||||
require 'tests/helpers/storage/file_tests'
|
||||
|
@ -35,15 +39,23 @@ end
|
|||
module Shindo
|
||||
class Tests
|
||||
|
||||
def formats(format, &block)
|
||||
def responds_to(method_names)
|
||||
for method_name in [*method_names]
|
||||
tests("#respond_to?(:#{method_name})").succeeds do
|
||||
@instance.respond_to?(method_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def formats(format)
|
||||
test('has proper format') do
|
||||
formats_kernel(instance_eval(&block), format)
|
||||
end
|
||||
end
|
||||
|
||||
def succeeds(&block)
|
||||
def succeeds
|
||||
test('succeeds') do
|
||||
instance_eval(&block)
|
||||
instance_eval(&Proc.new)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
30
tests/helpers/compute/flavors_tests.rb
Normal file
30
tests/helpers/compute/flavors_tests.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
def flavors_tests(connection, params = {}, mocks_implemented = true)
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#all").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
connection.flavors.all
|
||||
end
|
||||
|
||||
@identity = connection.flavors.first.identity
|
||||
|
||||
tests("#get('#{@identity}')").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
connection.flavors.get(@identity)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
invalid_flavor_identity = connection.flavors.first.identity.gsub(/\w/, '0')
|
||||
|
||||
tests("#get('#{invalid_flavor_identity}')").returns(nil) do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
connection.flavors.get(invalid_flavor_identity)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
16
tests/helpers/compute/server_tests.rb
Normal file
16
tests/helpers/compute/server_tests.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
def server_tests(connection, params = {}, mocks_implemented = true)
|
||||
|
||||
model_tests(connection.servers, params, mocks_implemented) do
|
||||
|
||||
responds_to([:ready?, :state])
|
||||
|
||||
tests('#reboot').succeeds do
|
||||
@instance.wait_for { ready? }
|
||||
@instance.reboot
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
|
||||
end
|
||||
|
||||
end
|
7
tests/helpers/compute/servers_tests.rb
Normal file
7
tests/helpers/compute/servers_tests.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
def servers_tests(connection, params, mocks_implemented = true)
|
||||
|
||||
collection_tests(connection.servers, params, mocks_implemented) do
|
||||
@instance.wait_for { ready? }
|
||||
end
|
||||
|
||||
end
|
|
@ -6,9 +6,7 @@ def directory_tests(connection, params = {:key => 'fogdirectorytests'}, mocks_im
|
|||
@instance.public=(true)
|
||||
end
|
||||
|
||||
tests("#respond_to?(:public_url)").succeeds do
|
||||
@instance.respond_to?(:public_url)
|
||||
end
|
||||
responds_to(:public_url)
|
||||
|
||||
end
|
||||
|
||||
|
|
5
tests/rackspace/models/compute/flavors_tests.rb
Normal file
5
tests/rackspace/models/compute/flavors_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('Rackspace::Compute | flavors collection', ['rackspace']) do
|
||||
|
||||
flavors_tests(Rackspace[:compute])
|
||||
|
||||
end
|
6
tests/rackspace/models/compute/server_tests.rb
Normal file
6
tests/rackspace/models/compute/server_tests.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Shindo.tests('Rackspace::Compute | server model', ['rackspace']) do
|
||||
|
||||
# image 49 = Ubuntu 10.04 LTS (lucid)
|
||||
server_tests(Rackspace[:compute], {:image_id => 49, :name => "fog_#{Time.now.to_i}"})
|
||||
|
||||
end
|
6
tests/rackspace/models/compute/servers_tests.rb
Normal file
6
tests/rackspace/models/compute/servers_tests.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Shindo.tests('Rackspace::Compute | servers collection', ['rackspace']) do
|
||||
|
||||
# image 49 = Ubuntu 10.04 LTS (lucid)
|
||||
servers_tests(Rackspace[:compute], {:image_id => 49, :name => "fog_#{Time.now.to_i}"})
|
||||
|
||||
end
|
5
tests/slicehost/models/compute/flavors_tests.rb
Normal file
5
tests/slicehost/models/compute/flavors_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('Slicehost::Compute | flavors collection', ['slicehost']) do
|
||||
|
||||
flavors_tests(Slicehost[:compute])
|
||||
|
||||
end
|
6
tests/slicehost/models/compute/server_tests.rb
Normal file
6
tests/slicehost/models/compute/server_tests.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Shindo.tests('Slicehost::Compute | server model', ['slicehost']) do
|
||||
|
||||
# image 49 = Ubuntu 10.04 LTS (lucid)
|
||||
server_tests(Slicehost[:compute], {:image_id => 49, :name => "fog_#{Time.now.to_i}")
|
||||
|
||||
end
|
6
tests/slicehost/models/compute/servers_tests.rb
Normal file
6
tests/slicehost/models/compute/servers_tests.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Shindo.tests('Slicehost::Compute | servers collection', ['slicehost']) do
|
||||
|
||||
# image 49 = Ubuntu 10.04 LTS (lucid)
|
||||
servers_tests(Slicehost[:compute], {:image_id => 49, :name => "fog_#{Time.now.to_i}"})
|
||||
|
||||
end
|
Loading…
Reference in a new issue