hammer_cli_foreman 2.1.2 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/release_notes.md +35 -4
- data/doc/testing.md +13 -0
- data/lib/hammer_cli_foreman.rb +0 -4
- data/lib/hammer_cli_foreman/architecture.rb +5 -5
- data/lib/hammer_cli_foreman/associating_commands.rb +4 -5
- data/lib/hammer_cli_foreman/auth.rb +4 -4
- data/lib/hammer_cli_foreman/bookmark.rb +6 -6
- data/lib/hammer_cli_foreman/command_extensions/ping.rb +10 -1
- data/lib/hammer_cli_foreman/command_extensions/status.rb +1 -1
- data/lib/hammer_cli_foreman/commands.rb +3 -1
- data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
- data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +1 -0
- data/lib/hammer_cli_foreman/config_group.rb +5 -5
- data/lib/hammer_cli_foreman/host.rb +3 -2
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +17 -10
- data/lib/hammer_cli_foreman/location.rb +2 -0
- data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
- data/lib/hammer_cli_foreman/model.rb +5 -5
- data/lib/hammer_cli_foreman/operating_system.rb +10 -9
- data/lib/hammer_cli_foreman/organization.rb +2 -0
- data/lib/hammer_cli_foreman/output/fields.rb +1 -1
- data/lib/hammer_cli_foreman/output/formatters.rb +1 -1
- data/lib/hammer_cli_foreman/ping.rb +20 -11
- data/lib/hammer_cli_foreman/references.rb +16 -0
- data/lib/hammer_cli_foreman/settings.rb +16 -2
- data/lib/hammer_cli_foreman/testing/api_expectations.rb +10 -0
- data/lib/hammer_cli_foreman/usergroup.rb +5 -5
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/minitest/coverage_reporter.rb +94 -0
- data/lib/minitest/hammer_coverage_plugin.rb +19 -0
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/functional/architecture_test.rb +49 -0
- data/test/functional/audit_test.rb +86 -63
- data/test/functional/bookmark_test.rb +20 -0
- data/test/functional/commands/list_test.rb +11 -11
- data/test/functional/compute_profile_test.rb +47 -2
- data/test/functional/config_group_test.rb +50 -0
- data/test/functional/filter_test.rb +114 -47
- data/test/functional/host_test.rb +105 -19
- data/test/functional/location_test.rb +134 -0
- data/test/functional/mail_notification_test.rb +20 -0
- data/test/functional/media_test.rb +130 -0
- data/test/functional/model_test.rb +50 -0
- data/test/functional/operating_system_test.rb +51 -0
- data/test/functional/organization_test.rb +52 -0
- data/test/functional/realm_test.rb +103 -0
- data/test/functional/role_test.rb +9 -12
- data/test/functional/settings_test.rb +78 -1
- data/test/functional/status_test.rb +79 -13
- data/test/functional/user_test.rb +39 -0
- data/test/functional/usergroup_test.rb +51 -0
- data/test/test_helper.rb +5 -2
- data/test/unit/api/interactive_basic_auth_test.rb +3 -1
- data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +2 -2
- data/test/unit/api/oauth/oauth_password_grant_test.rb +2 -2
- data/test/unit/api_test.rb +3 -4
- data/test/unit/apipie_resource_mock.rb +25 -4
- data/test/unit/architecture_test.rb +10 -1
- data/test/unit/bookmark_test.rb +99 -0
- data/test/unit/commands_test.rb +19 -19
- data/test/unit/common_parameter_test.rb +1 -1
- data/test/unit/compute_profile_test.rb +87 -0
- data/test/unit/config_group_test.rb +10 -0
- data/test/unit/dependency_resolver_test.rb +4 -4
- data/test/unit/exception_handler_test.rb +13 -13
- data/test/unit/helpers/command.rb +5 -5
- data/test/unit/helpers/resource_disabled.rb +2 -2
- data/test/unit/host_test.rb +1 -24
- data/test/unit/id_resolver_test.rb +23 -23
- data/test/unit/mail_notification_test.rb +53 -0
- data/test/unit/media_test.rb +1 -1
- data/test/unit/model_test.rb +10 -0
- data/test/unit/operating_system_test.rb +14 -1
- data/test/unit/option_builders_test.rb +49 -49
- data/test/unit/option_sources/id_params_test.rb +2 -2
- data/test/unit/option_sources/ids_params_test.rb +2 -2
- data/test/unit/output/formatters_test.rb +21 -21
- data/test/unit/param_filters_test.rb +17 -17
- data/test/unit/partition_table_test.rb +2 -2
- data/test/unit/role_test.rb +2 -2
- data/test/unit/sessions_test.rb +24 -24
- data/test/unit/settings_test.rb +4 -0
- data/test/unit/template_test.rb +1 -1
- data/test/unit/usergroup_test.rb +10 -0
- metadata +26 -7
- data/lib/hammer_cli_foreman/trend.rb +0 -47
- data/test/functional/trend_test.rb +0 -22
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'coverage_reporter'
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module Minitest
|
5
|
+
def self.plugin_hammer_coverage_options(opts, options)
|
6
|
+
opts.on "-c", "--coverage", "Generate coverage reports for API endpoints" do
|
7
|
+
options[:coverage] = true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.plugin_hammer_coverage_init(options)
|
12
|
+
if options[:coverage]
|
13
|
+
Minitest.reporter.reporters.clear
|
14
|
+
Minitest.after_run do
|
15
|
+
Minitest::CoverageRunner.new("test/data/#{ FOREMAN_VERSION }/foreman_api.json").run_tests
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
4
|
+
|
5
|
+
describe 'architecture' do
|
6
|
+
describe 'list' do
|
7
|
+
before do
|
8
|
+
@cmd = %w[architecture list]
|
9
|
+
@architectures = [{
|
10
|
+
id: 1,
|
11
|
+
name: 'i386',
|
12
|
+
}]
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return a list of architectures' do
|
16
|
+
api_expects(:architectures, :index, 'List architectures').returns(@architectures)
|
17
|
+
|
18
|
+
output = IndexMatcher.new([
|
19
|
+
%w[ID NAME],
|
20
|
+
%w[1 i386]
|
21
|
+
])
|
22
|
+
expected_result = success_result(output)
|
23
|
+
|
24
|
+
result = run_cmd(@cmd)
|
25
|
+
assert_cmd(expected_result, result)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should run list command with defaults' do
|
29
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.1')) }
|
30
|
+
defaults = HammerCLI::Defaults.new(
|
31
|
+
{
|
32
|
+
organization_id: {
|
33
|
+
provider: 'foreman'
|
34
|
+
},
|
35
|
+
location_id: {
|
36
|
+
provider: 'foreman'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
)
|
40
|
+
defaults.stubs(:write_to_file).returns(true)
|
41
|
+
defaults.stubs(:providers).returns(providers)
|
42
|
+
api_expects(:architectures, :index, 'List architectures').returns(@architectures)
|
43
|
+
|
44
|
+
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
45
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -1,28 +1,28 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
2
|
|
3
3
|
describe 'audit' do
|
4
|
-
|
4
|
+
before do
|
5
|
+
@audit_changed = {
|
6
|
+
'id' => 83,
|
7
|
+
'created_at' => "2017-10-31 11:25:44 UTC",
|
8
|
+
'remote_address' => '::1',
|
9
|
+
'user_name' => "foreman_api_admin",
|
10
|
+
'user_id' => 11,
|
11
|
+
'action' => "update",
|
12
|
+
'auditable_type' => "ProvisioningTemplate",
|
13
|
+
'auditable_name' => "default_location_subscribed_hosts",
|
14
|
+
'auditable_id' => 32,
|
15
|
+
'audited_changes' => {
|
16
|
+
'value' => [
|
17
|
+
nil,
|
18
|
+
"--- false\n..."
|
19
|
+
]
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
describe 'audit-info' do
|
5
24
|
let (:cmd) { ['audit', 'info'] }
|
6
25
|
let(:params) { ['--id=83'] }
|
7
|
-
let(:audit_changed) do
|
8
|
-
{
|
9
|
-
'id' => 83,
|
10
|
-
'created_at' => "2017-10-31 11:25:44 UTC",
|
11
|
-
'remote_address' => '::1',
|
12
|
-
'user_name' => "foreman_api_admin",
|
13
|
-
'user_id' => 11,
|
14
|
-
'action' => "update",
|
15
|
-
'auditable_type' => "ProvisioningTemplate",
|
16
|
-
'auditable_name' => "default_location_subscribed_hosts",
|
17
|
-
'auditable_id' => 32,
|
18
|
-
'audited_changes' => {
|
19
|
-
'value' => [
|
20
|
-
nil,
|
21
|
-
"--- false\n..."
|
22
|
-
]
|
23
|
-
}
|
24
|
-
}
|
25
|
-
end
|
26
26
|
let(:audit_new) do
|
27
27
|
{
|
28
28
|
"user_id" => 1,
|
@@ -62,24 +62,26 @@ describe 'audit' do
|
|
62
62
|
it 'shows audit information for changed records' do
|
63
63
|
api_expects(:audits, :show, 'info')
|
64
64
|
.with_params('id' => '83')
|
65
|
-
.returns(audit_changed)
|
65
|
+
.returns(@audit_changed)
|
66
66
|
|
67
|
-
output = OutputMatcher.new(
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
67
|
+
output = OutputMatcher.new(
|
68
|
+
[
|
69
|
+
'Id: 83',
|
70
|
+
'At: 2017/10/31 11:25:44',
|
71
|
+
'IP: ::1',
|
72
|
+
'User: foreman_api_admin',
|
73
|
+
'Action: update',
|
74
|
+
'Audit type: ProvisioningTemplate',
|
75
|
+
'Audit record: default_location_subscribed_hosts',
|
76
|
+
'Audited changes:',
|
77
|
+
' 1) Attribute: value',
|
78
|
+
' Old:',
|
79
|
+
'',
|
80
|
+
' New:',
|
81
|
+
' --- false',
|
82
|
+
' ...',
|
83
|
+
]
|
84
|
+
)
|
83
85
|
expected_result = success_result(output)
|
84
86
|
|
85
87
|
result = run_cmd(cmd + params)
|
@@ -91,36 +93,57 @@ describe 'audit' do
|
|
91
93
|
.with_params('id' => '83')
|
92
94
|
.returns(audit_new)
|
93
95
|
|
94
|
-
output = OutputMatcher.new(
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
96
|
+
output = OutputMatcher.new(
|
97
|
+
[
|
98
|
+
'Id: 63',
|
99
|
+
'At: 2017/10/09 23:42:44',
|
100
|
+
'IP: ::1',
|
101
|
+
'User: foreman_admin',
|
102
|
+
'Action: create',
|
103
|
+
'Audit type: User',
|
104
|
+
'Audit record: John Doe',
|
105
|
+
'Audited changes:',
|
106
|
+
' 1) Attribute: login',
|
107
|
+
' Value: john',
|
108
|
+
' 2) Attribute: firstname',
|
109
|
+
' Value: John',
|
110
|
+
' 3) Attribute: lastname',
|
111
|
+
' Value: Doe',
|
112
|
+
' 4) Attribute: mail',
|
113
|
+
' Value: john@ipa.test',
|
114
|
+
' 5) Attribute: admin',
|
115
|
+
' Value: false',
|
116
|
+
' 6) Attribute: auth_source_id',
|
117
|
+
' Value: 3',
|
118
|
+
' 7) Attribute: lower_login',
|
119
|
+
' Value: john',
|
120
|
+
' 8) Attribute: mail_enabled',
|
121
|
+
' Value: true',
|
122
|
+
]
|
123
|
+
)
|
120
124
|
expected_result = success_result(output)
|
121
125
|
|
122
126
|
result = run_cmd(cmd + params)
|
123
127
|
assert_cmd(expected_result, result)
|
124
128
|
end
|
125
129
|
end
|
130
|
+
|
131
|
+
describe 'audit-list' do
|
132
|
+
let(:cmd) { ['audit', 'list'] }
|
133
|
+
let(:audits) do
|
134
|
+
[@audit_changed]
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should show index list" do
|
138
|
+
api_expects(:audits, :index).returns(audits)
|
139
|
+
|
140
|
+
output = IndexMatcher.new([
|
141
|
+
['ID', 'AT', 'IP', 'USER', 'ACTION', 'AUDIT TYPE', 'AUDIT RECORD'],
|
142
|
+
['83', '2017/10/31 11:25:44', '::1', 'foreman_api_admin', 'update', 'ProvisioningTemplate', 'default_location_subscribed_hosts']
|
143
|
+
])
|
144
|
+
|
145
|
+
result = run_cmd(cmd)
|
146
|
+
assert_cmd(success_result(output), result)
|
147
|
+
end
|
148
|
+
end
|
126
149
|
end
|
@@ -27,6 +27,26 @@ describe 'bookmark' do
|
|
27
27
|
result = run_cmd(@cmd)
|
28
28
|
assert_cmd(expected_result, result)
|
29
29
|
end
|
30
|
+
|
31
|
+
it 'should run list command with defaults' do
|
32
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.1')) }
|
33
|
+
defaults = HammerCLI::Defaults.new(
|
34
|
+
{
|
35
|
+
organization_id: {
|
36
|
+
provider: 'foreman'
|
37
|
+
},
|
38
|
+
location_id: {
|
39
|
+
provider: 'foreman'
|
40
|
+
}
|
41
|
+
}
|
42
|
+
)
|
43
|
+
defaults.stubs(:write_to_file).returns(true)
|
44
|
+
defaults.stubs(:providers).returns(providers)
|
45
|
+
api_expects(:bookmarks, :index, 'List bookmarks').returns(@bookmarks)
|
46
|
+
|
47
|
+
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
48
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
49
|
+
end
|
30
50
|
end
|
31
51
|
|
32
52
|
describe 'info' do
|
@@ -39,12 +39,12 @@ describe HammerCLIForeman::ListCommand do
|
|
39
39
|
|
40
40
|
it 'shows search fields in help' do
|
41
41
|
result = run_cmd(cmd + params)
|
42
|
-
result.out.must_match(/.*Search \/ Order fields:\s+(\S+\s+\S+)*\s+name\s+string/)
|
42
|
+
_(result.out).must_match(/.*Search \/ Order fields:\s+(\S+\s+\S+)*\s+name\s+string/)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'formats enum values' do
|
46
46
|
result = run_cmd(cmd + params)
|
47
|
-
result.out.must_match(/.*Search \/ Order fields:\s+(\S+\s+\S+)*\s+managed\s+Values: true, false/)
|
47
|
+
_(result.out).must_match(/.*Search \/ Order fields:\s+(\S+\s+\S+)*\s+managed\s+Values: true, false/)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -53,7 +53,7 @@ describe HammerCLIForeman::ListCommand do
|
|
53
53
|
it "fetches only first page when there's not enough records" do
|
54
54
|
expect_paged_call(1, 1000, 10)
|
55
55
|
result = run_cmd([], {}, TestList)
|
56
|
-
result.exit_code.must_equal HammerCLI::EX_OK
|
56
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
57
57
|
end
|
58
58
|
|
59
59
|
it "fetches all records" do
|
@@ -62,27 +62,27 @@ describe HammerCLIForeman::ListCommand do
|
|
62
62
|
expect_paged_call(3, per_page_all, 10)
|
63
63
|
|
64
64
|
result = run_cmd([], {}, TestList)
|
65
|
-
result.exit_code.must_equal HammerCLI::EX_OK
|
65
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
66
66
|
end
|
67
67
|
|
68
68
|
it "uses --per-page value" do
|
69
69
|
per_page = 10
|
70
70
|
expect_paged_call(1, per_page, 10)
|
71
71
|
result = run_cmd(["--per-page=#{per_page}"], {}, TestList)
|
72
|
-
result.exit_code.must_equal HammerCLI::EX_OK
|
72
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
73
73
|
end
|
74
74
|
|
75
75
|
it "uses both --per-page and --page value" do
|
76
76
|
per_page = 10
|
77
77
|
expect_paged_call(2, per_page, 10)
|
78
78
|
result = run_cmd(["--per-page=#{per_page}", '--page=2'], {}, TestList)
|
79
|
-
result.exit_code.must_equal HammerCLI::EX_OK
|
79
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
80
80
|
end
|
81
81
|
|
82
82
|
it "sets per_page to 20 when only --page is used" do
|
83
83
|
expect_paged_call(2, 20, 10)
|
84
84
|
result = run_cmd(['--page=2'], {}, TestList)
|
85
|
-
result.exit_code.must_equal HammerCLI::EX_OK
|
85
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -96,20 +96,20 @@ describe HammerCLIForeman::ListCommand do
|
|
96
96
|
per_page = 10
|
97
97
|
expect_paged_call(1, per_page, 10)
|
98
98
|
result = run_cmd(["--per-page=#{per_page}"], {}, TestList)
|
99
|
-
result.exit_code.must_equal HammerCLI::EX_OK
|
99
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
100
100
|
end
|
101
101
|
|
102
102
|
it "respects per_page setting when the adapter allows pagination by default" do
|
103
103
|
expect_paged_call(1, per_page_in_settings, 30)
|
104
104
|
result = run_cmd([], { :adapter => :base, :interactive => false }, TestList)
|
105
|
-
result.exit_code.must_equal HammerCLI::EX_OK
|
105
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
106
106
|
end
|
107
107
|
|
108
108
|
it "fetches all records when the adapter doesn't allow pagination by default" do
|
109
109
|
expect_paged_call(1, per_page_all, 1000)
|
110
110
|
expect_paged_call(2, per_page_all, 10)
|
111
111
|
result = run_cmd([], { :adapter => :csv, :interactive => false }, TestList)
|
112
|
-
result.exit_code.must_equal HammerCLI::EX_OK
|
112
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -128,7 +128,7 @@ describe HammerCLIForeman::ListCommand do
|
|
128
128
|
|
129
129
|
result = run_cmd([], {}, TestListWithOutput)
|
130
130
|
assert_cmd(expected_result, result)
|
131
|
-
result.out.wont_match pagination_line_re
|
131
|
+
_(result.out).wont_match pagination_line_re
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'prints one page when --per-page is used' do
|
@@ -33,8 +33,10 @@ describe "parameters" do
|
|
33
33
|
}
|
34
34
|
end
|
35
35
|
it 'update compute profile name' do
|
36
|
-
params = ['--id=1'
|
37
|
-
api_expects(:compute_profiles, :update, 'Update the compute profile').with_params(
|
36
|
+
params = ['--id=1', '--new-name=profile2']
|
37
|
+
api_expects(:compute_profiles, :update, 'Update the compute profile').with_params(
|
38
|
+
{ 'compute_profile' => { 'name' => 'profile2' } }
|
39
|
+
).returns(@compute_profile)
|
38
40
|
result = run_cmd(@cmd + params)
|
39
41
|
assert_cmd(success_result("Compute profile updated.\n"), result)
|
40
42
|
end
|
@@ -96,4 +98,47 @@ describe "parameters" do
|
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
101
|
+
describe 'list' do
|
102
|
+
before do
|
103
|
+
@cmd = %w[compute-profile list]
|
104
|
+
@compute_profiles = [{
|
105
|
+
id: 1,
|
106
|
+
name: '1-Small',
|
107
|
+
}]
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should return a list of compute profiles' do
|
111
|
+
api_expects(:compute_profiles, :index, 'List compute profiles').returns(@compute_profiles)
|
112
|
+
|
113
|
+
output = IndexMatcher.new([
|
114
|
+
%w[ID NAME],
|
115
|
+
%w[1 1-Small]
|
116
|
+
])
|
117
|
+
expected_result = success_result(output)
|
118
|
+
|
119
|
+
result = run_cmd(@cmd)
|
120
|
+
assert_cmd(expected_result, result)
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should run list command with defaults' do
|
124
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.1')) }
|
125
|
+
defaults = HammerCLI::Defaults.new(
|
126
|
+
{
|
127
|
+
organization_id: {
|
128
|
+
provider: 'foreman'
|
129
|
+
},
|
130
|
+
location_id: {
|
131
|
+
provider: 'foreman'
|
132
|
+
}
|
133
|
+
}
|
134
|
+
)
|
135
|
+
defaults.stubs(:write_to_file).returns(true)
|
136
|
+
defaults.stubs(:providers).returns(providers)
|
137
|
+
api_expects(:compute_profiles, :index, 'List compute profiles').returns(@compute_profiles)
|
138
|
+
|
139
|
+
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
140
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
99
144
|
end
|