Sha256: 10bed863e99db54979ab4a834db0f979c3659d009c44780f5d71d18d1b52404f

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path '../../test_helper', __dir__
# Test class for Storage Account Model
class TestStorageAccount < Minitest::Test
  def setup
    @service = Fog::Storage::AzureRM.new(credentials)
    @storage_account = storage_account(@service)
    @response = ApiStub::Models::Storage::StorageAccount.create_storage_account
  end

  def test_model_methods
    methods = [
      :save,
      :destroy,
      :get_access_keys
    ]
    methods.each do |method|
      assert @storage_account.respond_to? method, true
    end
  end

  def test_model_attributes
    attributes = [
      :name,
      :location,
      :resource_group,
      :account_type
    ]
    @service.stub :create_storage_account, @response do
      attributes.each do |attribute|
        assert_respond_to @storage_account, attribute
      end
    end
  end

  def test_save_method_response
    @service.stub :create_storage_account, @response do
      assert_instance_of Fog::Storage::AzureRM::StorageAccount, @storage_account.save
    end
  end

  def test_get_access_keys_method_response
    response = {
      'key1' => 'key1 value',
      'key2' => 'key2 value'
    }
    @service.stub :get_storage_access_keys, response do
      assert_equal @storage_account.get_access_keys, response
    end
  end

  def test_destroy_method_true_response
    @service.stub :delete_storage_account, true do
      assert @storage_account.destroy
    end
  end

  def test_destroy_method_false_response
    @service.stub :delete_storage_account, false do
      assert !@storage_account.destroy
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.4 test/models/storage/test_storage_account.rb