hammer_cli_foreman 2.1.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -139,3 +139,137 @@ describe "parameters" do
|
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
|
+
|
|
143
|
+
describe 'create' do
|
|
144
|
+
before do
|
|
145
|
+
@cmd = %w(location create)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'should print error missing argument name' do
|
|
149
|
+
expected_result = "Could not create the location:\n Missing arguments for '--name'.\n"
|
|
150
|
+
|
|
151
|
+
api_expects(:locations, :index)
|
|
152
|
+
|
|
153
|
+
result = run_cmd(@cmd)
|
|
154
|
+
assert_match(expected_result, result.err)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it 'should create a location' do
|
|
158
|
+
params = ['--name=test-location']
|
|
159
|
+
|
|
160
|
+
api_expects(:locations, :index)
|
|
161
|
+
api_expects(:locations, :create, 'Create a locations') do |params|
|
|
162
|
+
(params['location']['name'] == 'test-location')
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
result = run_cmd(@cmd + params)
|
|
166
|
+
assert_cmd(success_result("Location created.\n"), result)
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
describe 'delete' do
|
|
171
|
+
before do
|
|
172
|
+
@cmd = %w(location delete)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
it 'should print error missing argument id' do
|
|
176
|
+
expected_result = "Could not delete the location:\n Missing arguments for '--id'.\n"
|
|
177
|
+
|
|
178
|
+
api_expects(:locations, :index)
|
|
179
|
+
|
|
180
|
+
result = run_cmd(@cmd)
|
|
181
|
+
assert_match(expected_result, result.err)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it 'should delete a location' do
|
|
185
|
+
params = ['--id=1']
|
|
186
|
+
|
|
187
|
+
api_expects(:locations, :index)
|
|
188
|
+
api_expects(:locations, :destroy, 'Delete a location').with_params(id: '1')
|
|
189
|
+
|
|
190
|
+
result = run_cmd(@cmd + params)
|
|
191
|
+
assert_cmd(success_result("Location deleted.\n"), result)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
describe 'info' do
|
|
196
|
+
before do
|
|
197
|
+
@cmd = ['location', 'info']
|
|
198
|
+
@location = {
|
|
199
|
+
id: 1,
|
|
200
|
+
title: 'Default Location',
|
|
201
|
+
name: 'Default Location',
|
|
202
|
+
users: [],
|
|
203
|
+
smart_proxies: [],
|
|
204
|
+
subnets: [],
|
|
205
|
+
compute_resources: [],
|
|
206
|
+
media: [],
|
|
207
|
+
ptables: [],
|
|
208
|
+
provisioning_templates: [],
|
|
209
|
+
domains: [],
|
|
210
|
+
realms: [],
|
|
211
|
+
environments: [],
|
|
212
|
+
hostgroups: [],
|
|
213
|
+
organizations: [],
|
|
214
|
+
parameters: []
|
|
215
|
+
}
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it 'should return the info of a location' do
|
|
219
|
+
params = ['--id', 1]
|
|
220
|
+
api_expects(:locations, :index)
|
|
221
|
+
api_expects(:locations, :show, 'Info location').returns(@location)
|
|
222
|
+
|
|
223
|
+
output = OutputMatcher.new([
|
|
224
|
+
'Id: 1',
|
|
225
|
+
'Title: Default Location',
|
|
226
|
+
'Name: Default Location',
|
|
227
|
+
'Users:',
|
|
228
|
+
'',
|
|
229
|
+
'Smart proxies:',
|
|
230
|
+
'',
|
|
231
|
+
'Subnets:',
|
|
232
|
+
'',
|
|
233
|
+
'Compute resources:',
|
|
234
|
+
'',
|
|
235
|
+
'Installation media:',
|
|
236
|
+
'',
|
|
237
|
+
'Templates:',
|
|
238
|
+
'',
|
|
239
|
+
'Partition Tables:',
|
|
240
|
+
'',
|
|
241
|
+
'Domains:',
|
|
242
|
+
'',
|
|
243
|
+
'Realms:',
|
|
244
|
+
'',
|
|
245
|
+
'Environments:',
|
|
246
|
+
'',
|
|
247
|
+
'Hostgroups:',
|
|
248
|
+
'',
|
|
249
|
+
'Parameters:',
|
|
250
|
+
])
|
|
251
|
+
|
|
252
|
+
expected_result = success_result(output)
|
|
253
|
+
result = run_cmd(@cmd + params)
|
|
254
|
+
assert_cmd(expected_result, result)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
describe 'update' do
|
|
259
|
+
before do
|
|
260
|
+
@cmd = ['location', 'update']
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it 'should update a location' do
|
|
264
|
+
params = ['--id=1', '--new-name=Default Location test']
|
|
265
|
+
|
|
266
|
+
api_expects(:locations, :index)
|
|
267
|
+
api_expects(:locations, :update, 'Update a location') do |params|
|
|
268
|
+
(params['location']['id'] == '1')
|
|
269
|
+
(params['location']['name'] == 'Default Location test')
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
result = run_cmd(@cmd + params)
|
|
273
|
+
assert_cmd(success_result("Location updated.\n"), result)
|
|
274
|
+
end
|
|
275
|
+
end
|
|
@@ -24,6 +24,26 @@ describe 'mail_notification' do
|
|
|
24
24
|
result = run_cmd(@cmd)
|
|
25
25
|
assert_cmd(expected_result, result)
|
|
26
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(:mail_notifications, :index, 'List mail notifications').returns(@mail_notifications)
|
|
43
|
+
|
|
44
|
+
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
|
45
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
|
46
|
+
end
|
|
27
47
|
end
|
|
28
48
|
|
|
29
49
|
describe 'info' do
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
|
2
|
+
|
|
3
|
+
describe 'medium' do
|
|
4
|
+
describe 'list' do
|
|
5
|
+
before do
|
|
6
|
+
@cmd = %w[medium list]
|
|
7
|
+
@media = [{
|
|
8
|
+
id: 1,
|
|
9
|
+
name: 'CentOS mirror',
|
|
10
|
+
path: 'http://mirror.centos.org/centos/$major/os/$arch',
|
|
11
|
+
os_family: 'Redhat',
|
|
12
|
+
operating_systems: [],
|
|
13
|
+
locations: [],
|
|
14
|
+
organizations: []
|
|
15
|
+
}]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should return a list of media' do
|
|
19
|
+
api_expects(:media, :index, 'List media').returns(@media)
|
|
20
|
+
|
|
21
|
+
output = IndexMatcher.new([
|
|
22
|
+
['ID', 'NAME', 'PATH'],
|
|
23
|
+
['1', 'CentOS mirror', 'http://mirror.centos.org/centos/$major/os/$arch']
|
|
24
|
+
])
|
|
25
|
+
expected_result = success_result(output)
|
|
26
|
+
|
|
27
|
+
result = run_cmd(@cmd)
|
|
28
|
+
assert_cmd(expected_result, result)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe 'info' do
|
|
33
|
+
before do
|
|
34
|
+
@cmd = ['medium', 'info']
|
|
35
|
+
@medium = {
|
|
36
|
+
id: 1,
|
|
37
|
+
name: 'CentOS mirror',
|
|
38
|
+
path: 'http://mirror.centos.org/centos/$major/os/$arch',
|
|
39
|
+
os_family: 'Redhat',
|
|
40
|
+
operating_systems: [],
|
|
41
|
+
locations: [],
|
|
42
|
+
organizations: []
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'should return the info of a medium' do
|
|
47
|
+
params = ['--id', 1]
|
|
48
|
+
api_expects(:media, :show, 'Info medium').returns(@medium)
|
|
49
|
+
|
|
50
|
+
output = OutputMatcher.new([
|
|
51
|
+
'Id: 1',
|
|
52
|
+
'Name: CentOS mirror',
|
|
53
|
+
'Path: http://mirror.centos.org/centos/$major/os/$arch',
|
|
54
|
+
'OS Family: Redhat'
|
|
55
|
+
])
|
|
56
|
+
|
|
57
|
+
expected_result = success_result(output)
|
|
58
|
+
result = run_cmd(@cmd + params)
|
|
59
|
+
assert_cmd(expected_result, result)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe 'create' do
|
|
64
|
+
before do
|
|
65
|
+
@cmd = %w(medium create)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'should print error missing argument name and path' do
|
|
69
|
+
expected_result = "Could not create the installation medium:\n Missing arguments for '--name', '--path'.\n"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
result = run_cmd(@cmd)
|
|
73
|
+
assert_match(expected_result, result.err)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'should create a media' do
|
|
77
|
+
params = ['--name=CentOS mirror', '--path=http://mirror.centos.org/centos/$major/os/$arch']
|
|
78
|
+
|
|
79
|
+
api_expects(:media, :create) do |params|
|
|
80
|
+
(params['medium']['name'] == 'CentOS mirror')
|
|
81
|
+
(params['medium']['path'] == 'http://mirror.centos.org/centos/$major/os/$arch')
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
result = run_cmd(@cmd + params)
|
|
85
|
+
assert_cmd(success_result("Installation medium created.\n"), result)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe 'delete' do
|
|
90
|
+
before do
|
|
91
|
+
@cmd = %w(medium delete)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'should print error missing argument id' do
|
|
95
|
+
expected_result = "Could not delete the installation media:\n Missing arguments for '--id'.\n"
|
|
96
|
+
|
|
97
|
+
api_expects_no_call
|
|
98
|
+
|
|
99
|
+
result = run_cmd(@cmd)
|
|
100
|
+
assert_match(expected_result, result.err)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'should delete a media' do
|
|
104
|
+
params = ['--id=1']
|
|
105
|
+
|
|
106
|
+
api_expects(:media, :destroy, 'Delete a media').with_params(id: '1')
|
|
107
|
+
|
|
108
|
+
result = run_cmd(@cmd + params)
|
|
109
|
+
assert_cmd(success_result("Installation medium deleted.\n"), result)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe 'update' do
|
|
114
|
+
before do
|
|
115
|
+
@cmd = ['medium', 'update']
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'should update a media' do
|
|
119
|
+
params = ['--id=1', '--new-name=CentOS mirror test']
|
|
120
|
+
|
|
121
|
+
api_expects(:media, :update, 'Update a media') do |params|
|
|
122
|
+
(params['medium']['id'] == '1')
|
|
123
|
+
(params['medium']['name'] == 'CentOS mirror test')
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
result = run_cmd(@cmd + params)
|
|
127
|
+
assert_cmd(success_result("Installation medium updated.\n"), result)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
|
4
|
+
|
|
5
|
+
describe 'model' do
|
|
6
|
+
describe 'list' do
|
|
7
|
+
before do
|
|
8
|
+
@cmd = %w[model list]
|
|
9
|
+
@models = [{
|
|
10
|
+
id: 1,
|
|
11
|
+
name: 'model',
|
|
12
|
+
}]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should return a list of models' do
|
|
16
|
+
api_expects(:models, :index, 'List models').returns(@models)
|
|
17
|
+
|
|
18
|
+
output = IndexMatcher.new([
|
|
19
|
+
%w[ID NAME],
|
|
20
|
+
%w[1 model]
|
|
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(:models, :index, 'List models').returns(@models)
|
|
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
|
+
|
|
50
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
|
4
|
+
|
|
5
|
+
describe 'operating_system' do
|
|
6
|
+
describe 'list' do
|
|
7
|
+
before do
|
|
8
|
+
@cmd = %w[os list]
|
|
9
|
+
@operating_system = [{
|
|
10
|
+
id: 1,
|
|
11
|
+
release_name: 'Redhat 7',
|
|
12
|
+
family: 'Redhat',
|
|
13
|
+
}]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should return a list of operating system' do
|
|
17
|
+
api_expects(:operatingsystems, :index, 'List operating systems').returns(@operating_system)
|
|
18
|
+
|
|
19
|
+
output = IndexMatcher.new([
|
|
20
|
+
['ID', 'RELEASE NAME', 'FAMILY'],
|
|
21
|
+
['1', 'Redhat 7', 'Redhat']
|
|
22
|
+
])
|
|
23
|
+
expected_result = success_result(output)
|
|
24
|
+
|
|
25
|
+
result = run_cmd(@cmd)
|
|
26
|
+
assert_cmd(expected_result, result)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should run list command with defaults' do
|
|
30
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.1')) }
|
|
31
|
+
defaults = HammerCLI::Defaults.new(
|
|
32
|
+
{
|
|
33
|
+
organization_id: {
|
|
34
|
+
provider: 'foreman'
|
|
35
|
+
},
|
|
36
|
+
location_id: {
|
|
37
|
+
provider: 'foreman'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
defaults.stubs(:write_to_file).returns(true)
|
|
42
|
+
defaults.stubs(:providers).returns(providers)
|
|
43
|
+
api_expects(:operatingsystems, :index, 'List operating systems').returns(@operating_system)
|
|
44
|
+
|
|
45
|
+
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
|
46
|
+
_(result.exit_code).must_equal HammerCLI::EX_OK
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
@@ -210,3 +210,55 @@ describe 'associating commands' do
|
|
|
210
210
|
end
|
|
211
211
|
end
|
|
212
212
|
end
|
|
213
|
+
|
|
214
|
+
describe 'create' do
|
|
215
|
+
before do
|
|
216
|
+
@cmd = %w(organization create)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it 'should print error missing argument name' do
|
|
220
|
+
expected_result = "Could not create the organization:\n Missing arguments for '--name'.\n"
|
|
221
|
+
|
|
222
|
+
api_expects(:organizations, :index)
|
|
223
|
+
|
|
224
|
+
result = run_cmd(@cmd)
|
|
225
|
+
assert_match(expected_result, result.err)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it 'should create an organization' do
|
|
229
|
+
params = ['--name=test-organization']
|
|
230
|
+
|
|
231
|
+
api_expects(:organizations, :index)
|
|
232
|
+
api_expects(:organizations, :create, 'Create an organization') do |params|
|
|
233
|
+
(params['organization']['name'] == 'test-organization')
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
result = run_cmd(@cmd + params)
|
|
237
|
+
assert_cmd(success_result("Organization created.\n"), result)
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
describe 'delete' do
|
|
242
|
+
before do
|
|
243
|
+
@cmd = %w(organization delete)
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
it 'should print error missing argument id' do
|
|
247
|
+
expected_result = "Could not delete the organization:\n Missing arguments for '--id'.\n"
|
|
248
|
+
|
|
249
|
+
api_expects(:organizations, :index)
|
|
250
|
+
|
|
251
|
+
result = run_cmd(@cmd)
|
|
252
|
+
assert_match(expected_result, result.err)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
it 'should delete an organization' do
|
|
256
|
+
params = ['--id=1']
|
|
257
|
+
|
|
258
|
+
api_expects(:organizations, :index)
|
|
259
|
+
api_expects(:organizations, :destroy, 'Delete an organization').with_params(id: '1')
|
|
260
|
+
|
|
261
|
+
result = run_cmd(@cmd + params)
|
|
262
|
+
assert_cmd(success_result("Organization deleted.\n"), result)
|
|
263
|
+
end
|
|
264
|
+
end
|