deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: Mock: Fix reporting wrong hardware profile when creating instances (DTACLOUD-364)
Date Mon, 10 Dec 2012 12:35:38 GMT
Updated Branches:
  refs/heads/master 45c8aa222 -> da8e09c0c


Mock: Fix reporting wrong hardware profile when creating instances (DTACLOUD-364)


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/da8e09c0
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/da8e09c0
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/da8e09c0

Branch: refs/heads/master
Commit: da8e09c0c2ef13e7da39933cbd3f939eb1d8ad2b
Parents: 45c8aa2
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Nov 22 13:53:40 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon Dec 10 11:20:27 2012 +0100

----------------------------------------------------------------------
 server/lib/deltacloud/drivers/base_driver.rb |   11 ++++-------
 server/tests/drivers/mock/instances_test.rb  |    6 ++++++
 2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/da8e09c0/server/lib/deltacloud/drivers/base_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index b828d33..c63f94f 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -106,18 +106,15 @@ module Deltacloud
 
     def find_hardware_profile(credentials, profile_id, image_id)
       hwp = nil
-      if name
+      if profile_id
         unless hwp = hardware_profile(credentials, profile_id)
-          raise BackendError.new(400, "bad-hardware-profile-name",
-                                 "Hardware profile '#{name}' does not exist", nil)
+          raise Exceptions.exception_from_status(400, "Hardware profile '#{profile_id}' does
not exists.")
         end
       else
         unless image = image(credentials, :id=>image_id)
-          raise BackendError.new(400, "bad-image-id",
-                                 "Image with ID '#{image_id}' does not exist", nil)
+          raise Exceptions.exception_from_status(400, "Image #{image_id} does not exists.")
         end
-        hwp = hardware_profiles(credentials,
-                                :architecture=>image.architecture).first
+        hwp = hardware_profiles(credentials, :architecture => image.architecture).first
       end
       return hwp
     end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/da8e09c0/server/tests/drivers/mock/instances_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/mock/instances_test.rb b/server/tests/drivers/mock/instances_test.rb
index 4c05136..686d1f3 100644
--- a/server/tests/drivers/mock/instances_test.rb
+++ b/server/tests/drivers/mock/instances_test.rb
@@ -54,6 +54,12 @@ describe 'MockDriver Instances' do
     @driver.instance(:id => instance.id).must_be_nil
   end
 
+  it 'must respond with proper error when using unknown hardware profile' do
+    Proc.new {
+      @driver.create_instance('img1', :name => 'inst2-test', :realm_id => 'us', :hwp_id
=> 'unknown')
+    }.must_raise Deltacloud::Exceptions::ValidationFailure
+  end
+
   it 'must allow to destroy created instance' do
     instance = @driver.create_instance('img1', :name => 'inst1-test-destroy')
     instance.must_be_kind_of Instance


Mime
View raw message