1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

rackspace - keypairs : redo exception/no-exception logic for ::destroy and ::get functions

This commit is contained in:
Bart Vercammen 2013-07-26 15:00:45 +02:00
parent 6db3f1ac06
commit 24deb48e01
3 changed files with 9 additions and 7 deletions

View file

@ -18,10 +18,8 @@ module Fog
end
def destroy
begin
service.delete_keypair(identity)
rescue Fog::Compute::RackspaceV2::NotFound
end
requires :identity
service.delete_keypair(identity)
true
end

View file

@ -18,7 +18,11 @@ module Fog
end
def get(key_id)
new(service.get_keypair(key_id).body['keypair'])
begin
new(service.get_keypair(key_id).body['keypair'])
rescue Fog::Compute::RackspaceV2::NotFound
nil
end
end
end

View file

@ -23,11 +23,11 @@ Shindo.tests('Fog::Compute::RackspaceV2 | keypairs', ['rackspace']) do
key == nil
end
tests("get unknown").raises(Fog::Compute::RackspaceV2::NotFound) do
tests("get unknown").returns(nil) do
service.keypairs.get(Fog::Mock.random_letters(32))
end
tests("delete unknown").returns(true) do
tests("delete unknown").raises(Fog::Compute::RackspaceV2::NotFound) do
service.keypairs.destroy(Fog::Mock.random_letters(32))
end