Sha256: 4178ef8e28da12be076868d41c533a20db7c0f91b111437a39b53f4693faea5b

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

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

# Test class for Record Set Model
class TestRecordSet < Minitest::Test
  def setup
    @service = Fog::DNS::AzureRM.new(credentials)
    @record_set = record_set(@service)
    @response = ApiStub::Models::DNS::RecordSet.create_record_set_obj
  end

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

  def test_model_attributes
    attributes = [
      :name,
      :resource_group,
      :zone_name,
      :records,
      :type,
      :ttl
    ]
    attributes.each do |attribute|
      assert @record_set.respond_to? attribute, true
    end
  end

  def test_save_method_response
    @service.stub :create_record_set, @response do
      assert_instance_of Fog::DNS::AzureRM::RecordSet, @record_set.save
    end
  end

  def test_destroy_method_true_response
    @service.stub :delete_record_set, true do
      assert @record_set.destroy
    end
  end

  def test_destroy_method_false_response
    @service.stub :delete_record_set, false do
      assert !@record_set.destroy
    end
  end

  def test_get_records_response
    @service.stub :get_records_from_record_set, ['4.3.2.1', '5.3.2.1'] do
      assert_equal @record_set.get_records('fog-test-rg', 'fog-test-record-set', 'fog-test-zone', 'A'), ['4.3.2.1', '5.3.2.1']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.4 test/models/dns/test_record_set.rb