mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Added find_by_name to openstack identity-users model and tests
This commit is contained in:
parent
adad1cf82a
commit
85eef15c4f
2 changed files with 18 additions and 0 deletions
|
@ -22,6 +22,15 @@ module Fog
|
|||
)
|
||||
end
|
||||
|
||||
def find_by_name(name)
|
||||
self.find {|user| user.name == name} ||
|
||||
Fog::Identity::OpenStack::User.new(
|
||||
service.get_user_by_name(name).body['user'].merge(
|
||||
'service' => service
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def destroy(id)
|
||||
user = self.find_by_id(id)
|
||||
user.destroy
|
||||
|
|
|
@ -14,6 +14,11 @@ Shindo.tests("Fog::Identity[:openstack] | users", ['openstack']) do
|
|||
user.id == @instance.id
|
||||
end
|
||||
|
||||
tests('#find_by_name').succeeds do
|
||||
user = Fog::Identity[:openstack].users.find_by_name(@instance.name)
|
||||
user.name == @instance.name
|
||||
end
|
||||
|
||||
tests('#destroy').succeeds do
|
||||
Fog::Identity[:openstack].users.destroy(@instance.id)
|
||||
end
|
||||
|
@ -26,6 +31,10 @@ Shindo.tests("Fog::Identity[:openstack] | users", ['openstack']) do
|
|||
Fog::Identity[:openstack].users.find_by_id('fake')
|
||||
end
|
||||
|
||||
tests('#find_by_name').raises(Fog::Identity::OpenStack::NotFound) do
|
||||
Fog::Identity[:openstack].users.find_by_name('fake')
|
||||
end
|
||||
|
||||
tests('#destroy').raises(Fog::Identity::OpenStack::NotFound) do
|
||||
Fog::Identity[:openstack].users.destroy('fake')
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue