Sha256: b24f40f985a5148ecec4cd4cc8d41ff68b2da7d6a6e0ab74f8ad98c96f548972

Contents?: true

Size: 1.7 KB

Versions: 14

Compression:

Stored size: 1.7 KB

Contents

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

# Test Class for List Storage Accounts For Resource Group Request
class TestListStorageAccountsForRG < 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_list_storage_accounts_for_rg_success
    response_body = ApiStub::Requests::Storage::StorageAccount.list_storage_accounts_for_rg(@storage_mgmt_client)
    @storage_accounts.stub :list_by_resource_group, response_body do
      assert @azure_credentials.list_storage_account_for_rg('gateway-RG').size >= 1
      @azure_credentials.list_storage_account_for_rg('gateway-RG').each do |s|
        assert_equal s.name, response_body.value[0].name
      end
    end
  end

  def test_list_storage_accounts_for_rg_failure
    response_body = ApiStub::Requests::Storage::StorageAccount.list_storage_accounts_for_rg(@storage_mgmt_client)
    @storage_accounts.stub :list_by_resource_group, response_body do
      assert_raises ArgumentError do
        @azure_credentials.list_storage_account_for_rg('gateway-RG', 'wrong argument')
      end
    end
  end

  def test_list_storage_accounts_for_rg_exception
    raise_exception = proc { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
    @storage_accounts.stub :list_by_resource_group, raise_exception do
      assert_raises(MsRestAzure::AzureOperationError) { @azure_credentials.list_storage_account_for_rg('gateway-RG') }
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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