Sha256: 52f551af4a442262a61a60c6099d1e9db8dcbd9039c84f4858e1724b53e65ec3

Contents?: true

Size: 1.86 KB

Versions: 31

Compression:

Stored size: 1.86 KB

Contents

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

# Test Class for Check Storage Account Request
class TestCheckStorageAccountNameAvailability < Minitest::Test
  # This class posesses the test cases for the requests of storage account service.
  def setup
    @azure_credentials = Fog::Storage::AzureRM.new(credentials)
    @storage_mgmt_client = @azure_credentials.instance_variable_get(:@storage_mgmt_client)
    @storage_accounts = @storage_mgmt_client.storage_accounts
  end

  def test_check_storage_account_name_availability_success
    true_case_response = ApiStub::Requests::Storage::StorageAccount.true_case_for_check_name_availability(@storage_mgmt_client)
    @storage_accounts.stub :check_name_availability, true_case_response do
      assert_equal @azure_credentials.check_storage_account_name_availability('teststorageaccount', 'Microsoft.Storage/storageAccounts'), true
    end
  end

  def test_check_storage_account_name_availability_failure
    false_case_response = ApiStub::Requests::Storage::StorageAccount.false_case_for_check_name_availability(@storage_mgmt_client)
    @storage_accounts.stub :check_name_availability, false_case_response do
      assert_equal @azure_credentials.check_storage_account_name_availability('testname', 'Microsoft.Storage/storageAccounts'), false
      assert_raises ArgumentError do
        @azure_credentials.check_storage_account_name_availability
      end
    end
  end

  def test_check_storage_account_name_availability_exception
    raise_exception = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
    @storage_accounts.stub :check_name_availability, raise_exception do
      assert_raises(RuntimeError) { @azure_credentials.check_storage_account_name_availability('teststorageaccount', 'Microsoft.Storage/storageAccounts') }
    end
  end
end

Version data entries

31 entries across 31 versions & 4 rubygems

Version Path
fog-azure-rm-0.4.5 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.5 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.4.4 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.4.3 test/requests/storage/test_check_storage_account_name_availability.rb
far-gem-0.5.1 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.4.2 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.4.1 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.4.0 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.3.9 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.3.8 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.3.7 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.3.6 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.3.5 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.3.4 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.4 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.3 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.3.3 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.2 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.1 test/requests/storage/test_check_storage_account_name_availability.rb
fog-azure-rm-0.3.2 test/requests/storage/test_check_storage_account_name_availability.rb