diff --git a/spec/aws/models/compute/flavors_spec.rb b/spec/aws/models/compute/flavors_spec.rb deleted file mode 100644 index 2636a2719..000000000 --- a/spec/aws/models/compute/flavors_spec.rb +++ /dev/null @@ -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 diff --git a/spec/aws/models/compute/servers_spec.rb b/spec/aws/models/compute/servers_spec.rb deleted file mode 100644 index 8d97e696c..000000000 --- a/spec/aws/models/compute/servers_spec.rb +++ /dev/null @@ -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 diff --git a/spec/bluebox/models/compute/flavors_spec.rb b/spec/bluebox/models/compute/flavors_spec.rb deleted file mode 100644 index 47f42f10e..000000000 --- a/spec/bluebox/models/compute/flavors_spec.rb +++ /dev/null @@ -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 diff --git a/spec/bluebox/models/compute/server_spec.rb b/spec/bluebox/models/compute/server_spec.rb deleted file mode 100644 index 1b31162df..000000000 --- a/spec/bluebox/models/compute/server_spec.rb +++ /dev/null @@ -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 diff --git a/spec/bluebox/models/compute/servers_spec.rb b/spec/bluebox/models/compute/servers_spec.rb deleted file mode 100644 index 39d06f61d..000000000 --- a/spec/bluebox/models/compute/servers_spec.rb +++ /dev/null @@ -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 diff --git a/spec/rackspace/models/compute/flavors_spec.rb b/spec/rackspace/models/compute/flavors_spec.rb deleted file mode 100644 index e1ddaab83..000000000 --- a/spec/rackspace/models/compute/flavors_spec.rb +++ /dev/null @@ -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 diff --git a/spec/rackspace/models/compute/server_spec.rb b/spec/rackspace/models/compute/server_spec.rb deleted file mode 100644 index d57fb331a..000000000 --- a/spec/rackspace/models/compute/server_spec.rb +++ /dev/null @@ -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 diff --git a/spec/rackspace/models/compute/servers_spec.rb b/spec/rackspace/models/compute/servers_spec.rb deleted file mode 100644 index b383040fd..000000000 --- a/spec/rackspace/models/compute/servers_spec.rb +++ /dev/null @@ -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 diff --git a/spec/slicehost/models/compute/flavors_spec.rb b/spec/slicehost/models/compute/flavors_spec.rb deleted file mode 100644 index 0b85d7d68..000000000 --- a/spec/slicehost/models/compute/flavors_spec.rb +++ /dev/null @@ -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 diff --git a/spec/slicehost/models/compute/server_spec.rb b/spec/slicehost/models/compute/server_spec.rb deleted file mode 100644 index cd2c82894..000000000 --- a/spec/slicehost/models/compute/server_spec.rb +++ /dev/null @@ -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 diff --git a/spec/slicehost/models/compute/servers_spec.rb b/spec/slicehost/models/compute/servers_spec.rb deleted file mode 100644 index efc72597f..000000000 --- a/spec/slicehost/models/compute/servers_spec.rb +++ /dev/null @@ -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 diff --git a/tests/aws/models/compute/flavors_tests.rb b/tests/aws/models/compute/flavors_tests.rb new file mode 100644 index 000000000..20d58d009 --- /dev/null +++ b/tests/aws/models/compute/flavors_tests.rb @@ -0,0 +1,5 @@ +Shindo.tests('AWS::Compute | flavors collection', ['aws']) do + + flavors_tests(AWS[:compute]) + +end diff --git a/tests/aws/models/compute/server_tests.rb b/tests/aws/models/compute/server_tests.rb new file mode 100644 index 000000000..81e39ae42 --- /dev/null +++ b/tests/aws/models/compute/server_tests.rb @@ -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 diff --git a/tests/aws/models/compute/servers_tests.rb b/tests/aws/models/compute/servers_tests.rb new file mode 100644 index 000000000..273fb1aa2 --- /dev/null +++ b/tests/aws/models/compute/servers_tests.rb @@ -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 diff --git a/tests/bluebox/models/compute/flavors_tests.rb b/tests/bluebox/models/compute/flavors_tests.rb new file mode 100644 index 000000000..9587108c5 --- /dev/null +++ b/tests/bluebox/models/compute/flavors_tests.rb @@ -0,0 +1,5 @@ +Shindo.tests('Bluebox::Compute | flavors collection', ['bluebox']) do + + flavors_tests(Bluebox[:compute]) + +end diff --git a/tests/bluebox/models/compute/server_tests.rb b/tests/bluebox/models/compute/server_tests.rb new file mode 100644 index 000000000..f6c5fc514 --- /dev/null +++ b/tests/bluebox/models/compute/server_tests.rb @@ -0,0 +1,5 @@ +Shindo.tests('Bluebox::Compute | server model', ['bluebox']) do + + server_tests(Bluebox[:compute], {:image_id => 'a00baa8f-b5d0-4815-8238-b471c4c4bf72'}) + +end diff --git a/tests/bluebox/models/compute/servers_tests.rb b/tests/bluebox/models/compute/servers_tests.rb new file mode 100644 index 000000000..7b167c8a7 --- /dev/null +++ b/tests/bluebox/models/compute/servers_tests.rb @@ -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 diff --git a/tests/helper.rb b/tests/helper.rb index d3a43c3ab..ee24cb0a8 100644 --- a/tests/helper.rb +++ b/tests/helper.rb @@ -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 diff --git a/tests/helpers/compute/flavors_tests.rb b/tests/helpers/compute/flavors_tests.rb new file mode 100644 index 000000000..fc7a9aa5b --- /dev/null +++ b/tests/helpers/compute/flavors_tests.rb @@ -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 diff --git a/tests/helpers/compute/server_tests.rb b/tests/helpers/compute/server_tests.rb new file mode 100644 index 000000000..f9271f11b --- /dev/null +++ b/tests/helpers/compute/server_tests.rb @@ -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 diff --git a/tests/helpers/compute/servers_tests.rb b/tests/helpers/compute/servers_tests.rb new file mode 100644 index 000000000..939874900 --- /dev/null +++ b/tests/helpers/compute/servers_tests.rb @@ -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 diff --git a/tests/helpers/storage/directory_tests.rb b/tests/helpers/storage/directory_tests.rb index fd550f8f2..d577c7ebe 100644 --- a/tests/helpers/storage/directory_tests.rb +++ b/tests/helpers/storage/directory_tests.rb @@ -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 diff --git a/tests/rackspace/models/compute/flavors_tests.rb b/tests/rackspace/models/compute/flavors_tests.rb new file mode 100644 index 000000000..c841fa327 --- /dev/null +++ b/tests/rackspace/models/compute/flavors_tests.rb @@ -0,0 +1,5 @@ +Shindo.tests('Rackspace::Compute | flavors collection', ['rackspace']) do + + flavors_tests(Rackspace[:compute]) + +end diff --git a/tests/rackspace/models/compute/server_tests.rb b/tests/rackspace/models/compute/server_tests.rb new file mode 100644 index 000000000..14f1acca5 --- /dev/null +++ b/tests/rackspace/models/compute/server_tests.rb @@ -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 diff --git a/tests/rackspace/models/compute/servers_tests.rb b/tests/rackspace/models/compute/servers_tests.rb new file mode 100644 index 000000000..1c6d59271 --- /dev/null +++ b/tests/rackspace/models/compute/servers_tests.rb @@ -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 diff --git a/tests/slicehost/models/compute/flavors_tests.rb b/tests/slicehost/models/compute/flavors_tests.rb new file mode 100644 index 000000000..593531f33 --- /dev/null +++ b/tests/slicehost/models/compute/flavors_tests.rb @@ -0,0 +1,5 @@ +Shindo.tests('Slicehost::Compute | flavors collection', ['slicehost']) do + + flavors_tests(Slicehost[:compute]) + +end diff --git a/tests/slicehost/models/compute/server_tests.rb b/tests/slicehost/models/compute/server_tests.rb new file mode 100644 index 000000000..9710b4bc6 --- /dev/null +++ b/tests/slicehost/models/compute/server_tests.rb @@ -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 diff --git a/tests/slicehost/models/compute/servers_tests.rb b/tests/slicehost/models/compute/servers_tests.rb new file mode 100644 index 000000000..120885ced --- /dev/null +++ b/tests/slicehost/models/compute/servers_tests.rb @@ -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