Sha256: 33e53415f3ba2c739190c26a33f06ab1cd021e8d4a30645a090e4965ad55f6d6

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

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

# Test class for Create Azure Resources Request
class TestTagResource < Minitest::Test
  def setup
    @service = Fog::Resources::AzureRM.new(credentials)
    @client = @service.instance_variable_get(:@rmc)
    @resources = @client.resources
    @resource_response = ApiStub::Requests::Resources::AzureResource.azure_resource_response(@client)
  end

  def test_tag_resource_success
    @resources.stub :get, @resource_response do
      @resources.stub :create_or_update, @resource_response do
        resource_id = '/subscriptions/########-####-####-####-############/resourceGroups/{RESOURCE-GROUP}/providers/Microsoft.Network/{PROVIDER-NAME}/{RESOURCE-NAME}'
        assert_equal @service.tag_resource(resource_id, 'tag_name', 'tag_value', 'api_version'), true
      end
    end
  end

  def test_tag_resource_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
    @resources.stub :get, @resource_response do
      @resources.stub :create_or_update, response do
        resource_id = '/subscriptions/########-####-####-####-############/resourceGroups/{RESOURCE-GROUP}/providers/Microsoft.Network/{PROVIDER-NAME}/{RESOURCE-NAME}'
        assert_raises(MsRestAzure::AzureOperationError) { @service.tag_resource(resource_id, 'tag_name', 'tag_value', 'api_version') }
      end
    end
  end

  def test_invalid_resource_id_exeception
    resource_id = 'Invalid-Resource-ID'
    assert_raises(RuntimeError) { @service.tag_resource(resource_id, 'tag_name', 'tag_value', 'api_version') }
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
fog-azure-rm-0.6.0 test/requests/resources/test_tag_resource.rb
fog-azure-rm-0.5.3 test/requests/resources/test_tag_resource.rb
fog-azure-rm-0.5.2 test/requests/resources/test_tag_resource.rb
far-gem-0.5.6 test/requests/resources/test_tag_resource.rb
fog-azure-rm-0.5.1 test/requests/resources/test_tag_resource.rb
far-gem-0.5.5 test/requests/resources/test_tag_resource.rb
fog-azure-rm-0.5.0 test/requests/resources/test_tag_resource.rb
far-gem-0.5.4 test/requests/resources/test_tag_resource.rb
far-gem-0.5.3 test/requests/resources/test_tag_resource.rb
fog-azure-rm-0.4.9 test/requests/resources/test_tag_resource.rb
far-gem-0.5.2 test/requests/resources/test_tag_resource.rb
fog-azure-rm-0.4.8 test/requests/resources/test_tag_resource.rb
fog-azure-rm-0.4.7 test/requests/resources/test_tag_resource.rb
fog-azure-rm-0.4.6 test/requests/resources/test_tag_resource.rb