Sha256: 32b0551fad6b9181018f2375babcd3fb2c1c0dcd4466f9b7004e7d6018a9e6b5

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require File.expand_path '../../test_helper', __dir__

# Test class for Resources Collection
class TestResources < Minitest::Test
  def setup
    @service = Fog::Resources::AzureRM.new(credentials)
    client = @service.instance_variable_get(:@rmc)
    @resources = Fog::Resources::AzureRM::AzureResources.new(service: @service, tag_name: 'tag_name', tag_value: 'tag_value')
    @response = ApiStub::Models::Resources::Resource.list_resources_response(client)
  end

  def test_collection_methods
    methods = [
      :all,
      :get
    ]
    methods.each do |method|
      assert @resources.respond_to? method, true
    end
  end

  def test_all_method_response
    @service.stub :list_tagged_resources, @response do
      assert_instance_of Fog::Resources::AzureRM::AzureResources, @resources.all
      assert @resources.all.size >= 1
      @resources.all.each do |r|
        assert_instance_of Fog::Resources::AzureRM::AzureResource, r
      end
    end
  end

  def test_get_method_response
    @service.stub :list_tagged_resources, @response do
      resource_id = '/subscriptions/########-####-####-####-############/resourceGroups/{RESOURCE-GROUP}/providers/Microsoft.Network/{PROVIDER-NAME}/{RESOURCE-NAME}'
      assert_instance_of Fog::Resources::AzureRM::AzureResource, @resources.get(resource_id)
      assert @resources.get('wrong-resource-id').nil?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.8 test/models/resources/test_resources.rb
fog-azure-rm-0.0.6 test/models/resources/test_resources.rb
fog-azure-rm-0.0.5 test/models/resources/test_resources.rb