Sha256: 9c618e89e83c69d19da7c78c703c25537bb01d4d3862f6e34299894cd1e0bba3

Contents?: true

Size: 1.83 KB

Versions: 33

Compression:

Stored size: 1.83 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)
    @resource_id = '/subscriptions/########-####-####-####-############/resourceGroups/{RESOURCE-GROUP}/providers/Microsoft.Network/{PROVIDER-NAME}/{RESOURCE-NAME}'
  end

  def test_collection_methods
    methods = [
      :all,
      :get,
      :check_azure_resource_exists
    ]
    methods.each do |method|
      assert_respond_to @resources, method
    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
      assert_instance_of Fog::Resources::AzureRM::AzureResource, @resources.get(@resource_id)
      assert @resources.get('wrong-resource-id').nil?
    end
  end

  def test_check_azure_resource_exists_true_response
    @service.stub :check_azure_resource_exists, true do
      assert @resources.check_azure_resource_exists(@resource_id, '2016-09-01')
    end
  end

  def test_check_azure_resource_exists_false_response
    @service.stub :check_azure_resource_exists, false do
      assert !@resources.check_azure_resource_exists(@resource_id, '2016-09-01')
    end
  end
end

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
fog-azure-rm-0.3.2 test/models/resources/test_resources.rb
fog-azure-rm-downgraded-0.3.1 test/models/resources/test_resources.rb
fog-azure-rm-0.3.1 test/models/resources/test_resources.rb
fog-azure-rm-downgraded-0.3.0 test/models/resources/test_resources.rb
fog-azure-rm-0.3.0 test/models/resources/test_resources.rb
fog-azure-rm-0.2.7 test/models/resources/test_resources.rb
fog-azure-rm-0.2.6 test/models/resources/test_resources.rb
fog-azure-rm-0.2.5 test/models/resources/test_resources.rb
fog-azure-rm-0.2.4 test/models/resources/test_resources.rb
fog-azure-rm-0.2.3 test/models/resources/test_resources.rb
fog-azure-rm-0.2.2 test/models/resources/test_resources.rb
fog-azure-rm-0.2.1 test/models/resources/test_resources.rb
fog-azure-rm-0.2.0 test/models/resources/test_resources.rb