Sha256: 9187d36ac4137c8128a6ee37d74340895b35f20cb95e1735c7e3866f224ebfc0

Contents?: true

Size: 1.82 KB

Versions: 12

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

require File.join(File.dirname(__FILE__), 'test_helper')

describe 'operating_system' do
  describe 'list' do
    before do
      @cmd = %w[os list]
      @operating_system = [{
                          id: 1,
                          release_name: 'Redhat 7',
                          family: 'Redhat',
                        }]
    end

    it 'should return a list of operating system' do
      api_expects(:operatingsystems, :index, 'List operating systems').returns(@operating_system)

      output = IndexMatcher.new([
                                  ['ID', 'RELEASE NAME', 'FAMILY'],
                                  ['1', 'Redhat 7', 'Redhat']
                                ])
      expected_result = success_result(output)

      result = run_cmd(@cmd)
      assert_cmd(expected_result, result)
    end

    it 'should run list command with defaults' do
      providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
      defaults = HammerCLI::Defaults.new(
        {
          organization_id: {
            provider: 'foreman'
          },
          location_id: {
            provider: 'foreman'
          }
        }
      )
      defaults.stubs(:write_to_file).returns(true)
      defaults.stubs(:providers).returns(providers)
      api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
      api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
      api_expects(:operatingsystems, :index, 'List operating systems').returns(@operating_system)

      result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
      _(result.exit_code).must_equal HammerCLI::EX_OK
    end
  end
end


Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hammer_cli_foreman-3.10.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.9.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.8.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.7.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.5.1 test/functional/operating_system_test.rb
hammer_cli_foreman-3.6.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.5.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.4.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.3.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.2.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.1.0 test/functional/operating_system_test.rb
hammer_cli_foreman-3.0.0 test/functional/operating_system_test.rb