Skip to content

Commit

Permalink
Add method all to images collection
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinLoiseau committed Oct 30, 2018
1 parent 8ff81af commit d530738
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/fog/azurerm/models/compute/images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ def create(attributes)
image.save
end

def all(async = false)
requires :resource_group
images = service.list_images(resource_group, async).map do |image|
Fog::Compute::AzureRM::Image.parse(image)
end
load(images)
end

def get(resource_group_name, image_name)
response = service.get_image(resource_group_name, image_name)
image = Fog::Compute::AzureRM::Image.new(service: service)
Expand Down
13 changes: 12 additions & 1 deletion test/models/compute/test_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@ def test_collection_attributes
end

def test_collection_methods
methods = %i(get create)
methods = %i(all get create)
methods.each do |method|
assert_respond_to @images, method
end
end

def test_all_method_response
@service.stub :list_images, [@image] do
images_list = @images.all
assert_instance_of Fog::Compute::AzureRM::Images, images_list
assert images_list.size >= 1
images_list.each do |image|
assert_instance_of Fog::Compute::AzureRM::Image, image
end
end
end

def test_get_method_response
@service.stub :get_image, @image do
assert_instance_of Fog::Compute::AzureRM::Image, @images.get('fog-test-rg', 'fog-test-image')
Expand Down

0 comments on commit d530738

Please sign in to comment.