Sha256: 569e36a766cf45f6b465e5798dd3ba156540b7cbd8b03fbc9aa18d1632e4bbb8

Contents?: true

Size: 1.64 KB

Versions: 12

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

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

describe 'model' do
  describe 'list' do
    before do
      @cmd = %w[model list]
      @models = [{
                          id: 1,
                          name: 'model',
                        }]
    end

    it 'should return a list of models' do
      api_expects(:models, :index, 'List models').returns(@models)

      output = IndexMatcher.new([
                                  %w[ID NAME],
                                  %w[1 model]
                                ])
      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(:models, :index, 'List models').returns(@models)

      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/model_test.rb
hammer_cli_foreman-3.9.0 test/functional/model_test.rb
hammer_cli_foreman-3.8.0 test/functional/model_test.rb
hammer_cli_foreman-3.7.0 test/functional/model_test.rb
hammer_cli_foreman-3.5.1 test/functional/model_test.rb
hammer_cli_foreman-3.6.0 test/functional/model_test.rb
hammer_cli_foreman-3.5.0 test/functional/model_test.rb
hammer_cli_foreman-3.4.0 test/functional/model_test.rb
hammer_cli_foreman-3.3.0 test/functional/model_test.rb
hammer_cli_foreman-3.2.0 test/functional/model_test.rb
hammer_cli_foreman-3.1.0 test/functional/model_test.rb
hammer_cli_foreman-3.0.0 test/functional/model_test.rb