From b7d2e03bc4696b7bdb1ed8320e8cba587abf4ec9 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Mon, 18 Jun 2018 17:45:52 +0100 Subject: [PATCH 1/2] Fix Cloudstack `#connection` deprecation warning Should be using `#service` instead in the volume tests. --- tests/cloudstack/compute/models/volume_tests.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cloudstack/compute/models/volume_tests.rb b/tests/cloudstack/compute/models/volume_tests.rb index 30c284492..41536942b 100644 --- a/tests/cloudstack/compute/models/volume_tests.rb +++ b/tests/cloudstack/compute/models/volume_tests.rb @@ -4,7 +4,7 @@ def volume_tests(connection, params, mocks_implemented = true) @instance.wait_for { ready? } end - @server = @instance.connection.servers.create(params[:server_attributes]) + @server = @instance.service.servers.create(params[:server_attributes]) @server.wait_for { ready? } tests('attach').succeeds do From 0bda54cff981dee7392bbcaa3a553cd4f298437b Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Mon, 18 Jun 2018 17:57:41 +0100 Subject: [PATCH 2/2] Remove tests for deprecated binary `#[]` Fog originally allowed use of `Provider[:service]` to generate a new instance of a service. This was deprecated since it was not portable. Using `AWS[:compute]` makes it harder to switch providers since all the classes needed renaming. Ideally `Compute[@provider]` would be used and can be configured within an application. The `fog` script ("binary") had a number of backwards-compatibility specs have been testing that the old methods worked. These generated deprecation warnings as they ran. Whilst the behaviour is still intact, this removes the tests that are creating deprecation noise since no one is likely to be using them. --- spec/fog/bin/atmos_spec.rb | 10 ---------- spec/fog/bin/aws_spec.rb | 18 ------------------ spec/fog/bin/baremetalcloud_spec.rb | 10 ---------- spec/fog/bin/bluebox_spec.rb | 18 ------------------ 4 files changed, 56 deletions(-) diff --git a/spec/fog/bin/atmos_spec.rb b/spec/fog/bin/atmos_spec.rb index 2fe9d052b..9067ad573 100644 --- a/spec/fog/bin/atmos_spec.rb +++ b/spec/fog/bin/atmos_spec.rb @@ -20,14 +20,4 @@ describe Atmos do end end end - - describe "#[]" do - describe "when requesting storage service" do - it "returns instance" do - Fog::Storage::Atmos.stub(:new, "instance") do - assert_equal "instance", Atmos[:storage] - end - end - end - end end diff --git a/spec/fog/bin/aws_spec.rb b/spec/fog/bin/aws_spec.rb index 4f7f30e60..6ae9d20f8 100644 --- a/spec/fog/bin/aws_spec.rb +++ b/spec/fog/bin/aws_spec.rb @@ -77,22 +77,4 @@ describe AWS do end end end - - describe "#[]" do - describe "when service is recognised" do - it "returns correct instance" do - KEY_CLASS_MAPPING.each do |key, klass| - klass.stub(:new, "#{klass} instance") do - assert_equal "#{klass} instance", AWS[key] - end - end - end - end - - describe "when service is not recognised" do - it "raises ArgumentError" do - assert_raises(ArgumentError) { AWS[:bad_service] } - end - end - end end diff --git a/spec/fog/bin/baremetalcloud_spec.rb b/spec/fog/bin/baremetalcloud_spec.rb index cc5e343bb..f2a9e53e0 100644 --- a/spec/fog/bin/baremetalcloud_spec.rb +++ b/spec/fog/bin/baremetalcloud_spec.rb @@ -20,14 +20,4 @@ describe BareMetalCloud do end end end - - describe "#[]" do - describe "when requesting compute service" do - it "returns instance" do - Fog::Compute::BareMetalCloud.stub(:new, "instance") do - assert_equal "instance", BareMetalCloud[:compute] - end - end - end - end end diff --git a/spec/fog/bin/bluebox_spec.rb b/spec/fog/bin/bluebox_spec.rb index 119a29205..5c94d0506 100644 --- a/spec/fog/bin/bluebox_spec.rb +++ b/spec/fog/bin/bluebox_spec.rb @@ -34,22 +34,4 @@ describe Bluebox do end end end - - describe "#[]" do - describe "when requesting compute service" do - it "returns instance" do - Fog::Compute::Bluebox.stub(:new, "instance") do - assert_equal "instance", Bluebox[:compute] - end - end - end - - describe "when requesting dns service" do - it "returns instance" do - Fog::DNS::Bluebox.stub(:new, "instance") do - assert_equal "instance", Bluebox[:dns] - end - end - end - end end