Sha256: 2259cc1604fa874c149347a097abcf89711dd6fe6cd70579811ec21ddf0b6fd1

Contents?: true

Size: 1.42 KB

Versions: 59

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'

module ForemanAnsible
  class OverrideResolverTest < ActiveSupport::TestCase
    test 'should return no overrides when no roles assigned to host' do
      assert_empty OverrideResolver.new(FactoryBot.build(:host)).overrides
    end

    test 'should return overrides for host' do
      first_role = FactoryBot.create(:ansible_role)
      first_var = FactoryBot.create(:ansible_variable, :override => true, :ansible_role => first_role)
      second_role = FactoryBot.create(:ansible_role)
      second_var = FactoryBot.create(:ansible_variable, :override => true, :ansible_role => second_role)
      host = FactoryBot.create(:host, :ansible_roles => [first_role])
      another_host = FactoryBot.create(:host)

      FactoryBot.create(:lookup_value, :match => "fqdn=#{host.name}", :lookup_key_id => first_var.id)
      FactoryBot.create(:lookup_value, :match => "fqdn=#{another_host.name}", :lookup_key_id => first_var.id)
      FactoryBot.create(:lookup_value, :match => "fqdn=#{host.name}", :lookup_key_id => second_var.id)

      assert_not_nil OverrideResolver.new(host).resolve(first_var)
      assert_nil OverrideResolver.new(another_host).resolve(first_var)
      assert_nil OverrideResolver.new(host).resolve(second_var)
    end

    test 'should raise when no host specified' do
      assert_raises Foreman::Exception do
        OverrideResolver.new(nil)
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
foreman_ansible-15.0.3 test/unit/services/override_resolver_test.rb
foreman_ansible-15.0.2 test/unit/services/override_resolver_test.rb
foreman_ansible-15.0.1 test/unit/services/override_resolver_test.rb
foreman_ansible-15.0.0 test/unit/services/override_resolver_test.rb
foreman_ansible-14.2.2 test/unit/services/override_resolver_test.rb
foreman_ansible-14.2.1 test/unit/services/override_resolver_test.rb
foreman_ansible-13.0.7 test/unit/services/override_resolver_test.rb
foreman_ansible-14.2.0 test/unit/services/override_resolver_test.rb
foreman_ansible-14.1.1 test/unit/services/override_resolver_test.rb
foreman_ansible-14.1.0 test/unit/services/override_resolver_test.rb
foreman_ansible-13.0.5 test/unit/services/override_resolver_test.rb
foreman_ansible-14.0.0 test/unit/services/override_resolver_test.rb
foreman_ansible-13.0.4 test/unit/services/override_resolver_test.rb
foreman_ansible-13.0.3 test/unit/services/override_resolver_test.rb
foreman_ansible-13.0.2 test/unit/services/override_resolver_test.rb
foreman_ansible-13.0.1 test/unit/services/override_resolver_test.rb
foreman_ansible-13.0.0 test/unit/services/override_resolver_test.rb
foreman_ansible-12.0.7 test/unit/services/override_resolver_test.rb
foreman_ansible-10.4.4 test/unit/services/override_resolver_test.rb
foreman_ansible-7.1.8 test/unit/services/override_resolver_test.rb