Sha256: 7bc3c398efdf30acc10fc88fb1163ba11b26fe87598e2d045e6b967d912c6d12

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

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

# Test class for Check Vault Exists Request
class TestCheckVaultExists < Minitest::Test
  def setup
    @service = Fog::KeyVault::AzureRM.new(credentials)
    @key_vault_client = @service.instance_variable_get(:@key_vault_client)
    @vaults = @key_vault_client.vaults
  end

  def test_check_vault_exists_success
    response = ApiStub::Requests::KeyVault::Vault.create_vault_response(@key_vault_client)
    @vaults.stub :get, response do
      assert @service.check_vault_exists('fog-test-rg', 'fog-test-kv')
    end
  end

  def test_check_vault_exists_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
    @vaults.stub :get, response do
      assert !@service.check_vault_exists('fog-test-rg', 'fog-test-kv')
    end
  end

  def test_check_vault_resource_group_exists_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
    @vaults.stub :get, response do
      assert !@service.check_vault_exists('fog-test-rg', 'fog-test-kv')
    end
  end

  def test_check_vault_exists_exception
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
    @vaults.stub :get, response do
      assert_raises(RuntimeError) { @service.check_vault_exists('fog-test-rg', 'fog-test-kv') }
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
fog-azure-rm-0.4.5 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-temp-0.0.5 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.4.4 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.4.3 test/requests/key_vault/test_check_vault_exists.rb
far-gem-0.5.1 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.4.2 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.4.1 test/requests/key_vault/test_check_vault_exists.rb