Sha256: fb2a72d141c42cbff59fd48ae6448060d0a1af84100ef8176c859ff48dfb7273

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

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

# Test class for Database Model
class TestDatabase < Minitest::Test
  def setup
    @service = Fog::Sql::AzureRM.new(credentials)
    @database = database(@service)
  end

  def test_model_methods
    methods = [
      :save,
      :destroy
    ]
    methods.each do |method|
      assert_respond_to @database, method
    end
  end

  def test_model_attributes
    attributes = [
      :name,
      :id,
      :resource_group,
      :server_name,
      :type,
      :collation,
      :create_mode,
      :creation_date,
      :current_service_level_objective_id,
      :database_id,
      :default_secondary_location,
      :edition,
      :earliest_restore_date,
      :elastic_pool_name,
      :location,
      :max_size_bytes,
      :requested_service_objective_id,
      :requested_service_objective_name,
      :restore_point_in_time,
      :service_level_objective,
      :source_database_id,
      :source_database_deletion_date
    ]
    attributes.each do |attribute|
      assert_respond_to @database, attribute
    end
  end

  def test_save_method_response
    create_response = ApiStub::Models::Sql::SqlDatabase.create_database
    @service.stub :create_or_update_database, create_response do
      assert_instance_of Fog::Sql::AzureRM::SqlDatabase, @database.save
    end
  end

  def test_destroy_method_true_response
    @service.stub :delete_database, true do
      assert @database.destroy
    end
  end

  def test_destroy_method_false_response
    @service.stub :delete_database, false do
      assert !@database.destroy
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-azure-rm-0.1.1 test/models/sql/test_database.rb
fog-azure-rm-0.1.0 test/models/sql/test_database.rb
fog-azure-rm-0.0.9 test/models/sql/test_database.rb