Sha256: 6e8d1818d95d3d9f8a8caa0160f92c9a337e0c08d8e8d451dffcf893321ff92c

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

require 'test_plugin_helper'

module ForemanSalt
  class HostgroupExtensionsTest < ActiveSupport::TestCase
    setup do
      User.current = User.find_by_login "admin"
    end

    test "host group has a salt smart proxy" do
      hostgroup = FactoryGirl.create :hostgroup, :with_salt_proxy
      assert hostgroup.salt_proxy.features.map(&:name).include? 'Salt'
    end

    test "nested host group inherits salt modules from parent" do
      parent = FactoryGirl.create :hostgroup, :with_salt_modules
      child = FactoryGirl.create :hostgroup, :parent => parent
      assert_equal [], parent.salt_modules - child.salt_modules
    end

    test "child host group inherits salt proxy from child parent" do
      parent = FactoryGirl.create :hostgroup
      child_one = FactoryGirl.create :hostgroup, :with_salt_proxy, :parent => parent
      child_two = FactoryGirl.create :hostgroup, :parent => child_one
      assert_equal child_two.salt_proxy, child_one.salt_proxy
    end

    test "child and parent salt modules are combined" do
      parent = FactoryGirl.create :hostgroup, :with_salt_modules
      child = FactoryGirl.create :hostgroup, :with_salt_modules, :parent => parent
      assert_equal 10, (child.salt_modules - parent.salt_modules).length
    end

    test "second child inherits from parent" do
      parent = FactoryGirl.create :hostgroup, :with_salt_modules
      child_one = FactoryGirl.create :hostgroup, :parent => parent 
      child_two = FactoryGirl.create :hostgroup, :parent => child_one
      assert_equal [], parent.salt_modules - child_two.salt_modules
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_salt-1.1.0 test/unit/hostgroup_extensions_test.rb
foreman_salt-1.0.0 test/unit/hostgroup_extensions_test.rb
foreman_salt-0.0.4 test/unit/hostgroup_extensions_test.rb
foreman_salt-0.0.3 test/unit/hostgroup_extensions_test.rb
foreman_salt-0.0.2 test/unit/hostgroup_extensions_test.rb