Sha256: 9618a3d07e375c3534824ecc77e70622acaab173a13847ad303ca9f6d75fceac

Contents?: true

Size: 1.97 KB

Versions: 14

Compression:

Stored size: 1.97 KB

Contents

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

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

  def test_check_storage_account_exists_success
    response_body = ApiStub::Requests::Storage::StorageAccount.storage_account_request(@storage_mgmt_client)
    response_body.provisioning_state = 'Succeeded'
    @storage_accounts.stub :get_properties, response_body do
      assert_equal @service.check_storage_account_exists('fog_test_rg', 'fog-test-storage-account'), true
    end
  end

  def test_check_storage_account_exists_failure
    response = ApiStub::Requests::Storage::StorageAccount.storage_account_request(@storage_mgmt_client)
    response.provisioning_state = 'Failed'
    @storage_accounts.stub :get_properties, response do
      assert !@service.check_storage_account_exists('fog_test_rg', 'fogtestsasecond')
    end
  end

  def test_check_storage_account_resource_group_exists_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
    @storage_accounts.stub :get_properties, response do
      assert !@service.check_storage_account_exists('fog_test_rg', 'fogtestsasecond')
    end
  end

  def test_check_storage_account_exists_exception
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
    @storage_accounts.stub :get_properties, response do
      assert_raises(MsRestAzure::AzureOperationError) { @service.check_storage_account_exists('fog_test_rg', 'fogtestsasecond') }
    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_check_storage_account_exists.rb
fog-azure-rm-0.5.3 test/requests/storage/test_check_storage_account_exists.rb
fog-azure-rm-0.5.2 test/requests/storage/test_check_storage_account_exists.rb
far-gem-0.5.6 test/requests/storage/test_check_storage_account_exists.rb
fog-azure-rm-0.5.1 test/requests/storage/test_check_storage_account_exists.rb
far-gem-0.5.5 test/requests/storage/test_check_storage_account_exists.rb
fog-azure-rm-0.5.0 test/requests/storage/test_check_storage_account_exists.rb
far-gem-0.5.4 test/requests/storage/test_check_storage_account_exists.rb
far-gem-0.5.3 test/requests/storage/test_check_storage_account_exists.rb
fog-azure-rm-0.4.9 test/requests/storage/test_check_storage_account_exists.rb
far-gem-0.5.2 test/requests/storage/test_check_storage_account_exists.rb
fog-azure-rm-0.4.8 test/requests/storage/test_check_storage_account_exists.rb
fog-azure-rm-0.4.7 test/requests/storage/test_check_storage_account_exists.rb
fog-azure-rm-0.4.6 test/requests/storage/test_check_storage_account_exists.rb