Sha256: 76935106ab15392f60e455dfc09474739cb7251f65e5a7b18089643482743d2e

Contents?: true

Size: 1.81 KB

Versions: 31

Compression:

Stored size: 1.81 KB

Contents

describe HybridPlatformsConductor::NodesHandler do

  context 'checking config DSL' do

    it 'adds helpers for master cmdbs' do
      with_test_platform(
        {
          nodes: {
            'node1' => {},
            'node2' => {},
            'node3' => {}
          }
        },
        false,
        '
          master_cmdbs(
            test_cmdb: :property1,
            test_cmdb2: :property2
          )
          for_nodes(\'node2\') do
            master_cmdbs(test_cmdb: :property3)
          end
        '
      ) do
        register_test_cmdb(%i[test_cmdb test_cmdb2])
        expect(test_config.cmdb_masters).to eq [
          {
            nodes_selectors_stack: [],
            cmdb_masters: {
              test_cmdb: [:property1],
              test_cmdb2: [:property2]
            }
          },
          {
            nodes_selectors_stack: ['node2'],
            cmdb_masters: {
              test_cmdb: [:property3]
            }
          }
        ]
      end
    end

    it 'adds helpers for configurable sudo' do
      with_test_platform(
        {
          nodes: {
            'node1' => {},
            'node2' => {},
            'node3' => {}
          }
        },
        false,
        '
          sudo_for { |user| "alt_sudo1 -p #{user}" }
          for_nodes(\'node2\') do
            sudo_for { |user| "alt_sudo2 -q #{user}" }
          end
        '
      ) do
        expect(test_config.sudo_procs.size).to eq 2
        expect(test_config.sudo_procs[0][:nodes_selectors_stack]).to eq []
        expect(test_config.sudo_procs[0][:sudo_proc].call('test_user')).to eq 'alt_sudo1 -p test_user'
        expect(test_config.sudo_procs[1][:nodes_selectors_stack]).to eq ['node2']
        expect(test_config.sudo_procs[1][:sudo_proc].call('test_user')).to eq 'alt_sudo2 -q test_user'
      end
    end

  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-32.10.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.9.1 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.9.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.8.2 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.8.1 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.8.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.7.3 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.7.2 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.7.1 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.7.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb
hybrid_platforms_conductor-32.6.0 spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb