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
@@ -44,11 +44,13 @@ describe HammerCLIForeman::Api::InteractiveBasicAuth do
|
|
44
44
|
|
45
45
|
context "non-interactive mode" do
|
46
46
|
it "doesn't ask for credentials when they're not provided" do
|
47
|
+
HammerCLI.stubs(:interactive?).returns false
|
47
48
|
auth = HammerCLIForeman::Api::InteractiveBasicAuth.new(nil, nil)
|
48
49
|
auth.expects(:ask_user).never
|
49
|
-
|
50
50
|
request.expects(:basic_auth).with(nil, nil)
|
51
51
|
auth.authenticate(request, args)
|
52
|
+
HammerCLI.unstub(:interactive?)
|
53
|
+
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -23,13 +23,13 @@ describe HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant do
|
|
23
23
|
it 'sets token as nil when all input parameter are missing' do
|
24
24
|
auth.stubs(:get_code).returns('code')
|
25
25
|
auth.set_token(nil, nil, nil, nil)
|
26
|
-
|
26
|
+
assert_nil auth.token
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'sets token as nil when any input parameter is missing' do
|
30
30
|
auth.stubs(:get_code).returns('code')
|
31
31
|
auth.set_token(nil, params[:oidc_authorization_endpoint], params[:oidc_client_id], params[:oidc_redirect_uri])
|
32
|
-
|
32
|
+
assert_nil auth.token
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -22,12 +22,12 @@ describe HammerCLIForeman::Api::Oauth::PasswordGrant do
|
|
22
22
|
|
23
23
|
it 'sets token as nil when all input parameter are missing' do
|
24
24
|
auth.set_token(nil, nil, nil, nil)
|
25
|
-
|
25
|
+
assert_nil auth.token
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'sets token as nil when any input parameter is missing' do
|
29
29
|
auth.set_token(nil, params[:oidc_client_id], params[:username], params[:password])
|
30
|
-
|
30
|
+
assert_nil auth.token
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
data/test/unit/api_test.rb
CHANGED
@@ -9,17 +9,16 @@ describe HammerCLIForeman do
|
|
9
9
|
let(:expected_resource) { HammerCLIForeman.foreman_resource!(:architectures) }
|
10
10
|
|
11
11
|
it "finds resource for params with _id" do
|
12
|
-
HammerCLIForeman.param_to_resource("architecture_id").name.must_equal expected_resource.name
|
12
|
+
_(HammerCLIForeman.param_to_resource("architecture_id").name).must_equal expected_resource.name
|
13
13
|
end
|
14
14
|
|
15
15
|
it "finds resource for params without _id" do
|
16
|
-
HammerCLIForeman.param_to_resource("architecture").name.must_equal expected_resource.name
|
16
|
+
_(HammerCLIForeman.param_to_resource("architecture").name).must_equal expected_resource.name
|
17
17
|
end
|
18
18
|
|
19
19
|
it "returns nil for unknown resource" do
|
20
|
-
HammerCLIForeman.param_to_resource("unknown")
|
20
|
+
assert_nil HammerCLIForeman.param_to_resource("unknown")
|
21
21
|
end
|
22
|
-
|
23
22
|
end
|
24
23
|
|
25
24
|
end
|
@@ -237,6 +237,27 @@ module ResourceMocks
|
|
237
237
|
)
|
238
238
|
end
|
239
239
|
|
240
|
+
def self.bookmarks
|
241
|
+
ResourceMocks.mock_action_calls(
|
242
|
+
[:bookmarks, :index, []],
|
243
|
+
[:bookmarks, :show, {}]
|
244
|
+
)
|
245
|
+
end
|
246
|
+
|
247
|
+
def self.mail_notifications
|
248
|
+
ResourceMocks.mock_action_calls(
|
249
|
+
[:mail_notifications, :index, []],
|
250
|
+
[:mail_notifications, :show, {}]
|
251
|
+
)
|
252
|
+
end
|
253
|
+
|
254
|
+
def self.compute_profiles
|
255
|
+
ResourceMocks.mock_action_calls(
|
256
|
+
[:compute_profiles, :index, []],
|
257
|
+
[:compute_profiles, :show, {}]
|
258
|
+
)
|
259
|
+
end
|
260
|
+
|
240
261
|
def self.parameters_index
|
241
262
|
ResourceMocks.mock_action_call(:parameters, :index, [])
|
242
263
|
end
|
@@ -308,11 +329,11 @@ module ResourceMocks
|
|
308
329
|
)
|
309
330
|
end
|
310
331
|
|
311
|
-
def self.
|
312
|
-
ResourceMocks.mock_action_call(:common_parameters, :
|
332
|
+
def self.common_parameter_list
|
333
|
+
ResourceMocks.mock_action_call(:common_parameters, :index, [{
|
313
334
|
"name" => "my param",
|
314
|
-
"value" => "random value"
|
315
|
-
})
|
335
|
+
"value" => "random value",
|
336
|
+
}])
|
316
337
|
end
|
317
338
|
|
318
339
|
def self.config_groups_index
|
@@ -17,6 +17,8 @@ describe HammerCLIForeman::Architecture do
|
|
17
17
|
context "parameters" do
|
18
18
|
it_should_accept "no arguments"
|
19
19
|
it_should_accept_search_params
|
20
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
21
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
20
22
|
end
|
21
23
|
|
22
24
|
context "output" do
|
@@ -37,6 +39,8 @@ describe HammerCLIForeman::Architecture do
|
|
37
39
|
context "parameters" do
|
38
40
|
it_should_accept "id", ["--id=1"]
|
39
41
|
it_should_accept "name", ["--name=arch"]
|
42
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
43
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
40
44
|
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
41
45
|
end
|
42
46
|
|
@@ -57,6 +61,8 @@ describe HammerCLIForeman::Architecture do
|
|
57
61
|
|
58
62
|
context "parameters" do
|
59
63
|
it_should_accept "name", ["--name=arch"]
|
64
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
65
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
60
66
|
# it_should_fail_with "name missing", []
|
61
67
|
# TODO: temporarily disabled, parameters are checked in the api
|
62
68
|
end
|
@@ -71,6 +77,8 @@ describe HammerCLIForeman::Architecture do
|
|
71
77
|
context "parameters" do
|
72
78
|
it_should_accept "name", ["--name=arch"]
|
73
79
|
it_should_accept "id", ["--id=1"]
|
80
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
81
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
74
82
|
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
75
83
|
end
|
76
84
|
|
@@ -84,9 +92,10 @@ describe HammerCLIForeman::Architecture do
|
|
84
92
|
context "parameters" do
|
85
93
|
it_should_accept "name", ["--name=arch", "--new-name=arch2"]
|
86
94
|
it_should_accept "id", ["--id=1", "--new-name=arch2"]
|
95
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
96
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
87
97
|
# it_should_fail_with "no params", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
88
98
|
# it_should_fail_with "name or id missing", ["--new-name=arch2"] # TODO: temporarily disabled, parameters are checked in the id resolver
|
89
99
|
end
|
90
|
-
|
91
100
|
end
|
92
101
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
4
|
+
require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
5
|
+
|
6
|
+
require 'hammer_cli_foreman/bookmark'
|
7
|
+
|
8
|
+
describe HammerCLIForeman::Bookmark do
|
9
|
+
include CommandTestHelper
|
10
|
+
|
11
|
+
context 'ListCommand' do
|
12
|
+
before :each do
|
13
|
+
ResourceMocks.bookmarks
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:cmd) { HammerCLIForeman::Bookmark::ListCommand.new('', ctx) }
|
17
|
+
|
18
|
+
context 'parameters' do
|
19
|
+
it_should_accept 'no arguments'
|
20
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
21
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'output' do
|
25
|
+
let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
|
26
|
+
|
27
|
+
it_should_print_n_records
|
28
|
+
it_should_print_column 'Id'
|
29
|
+
it_should_print_column 'Name'
|
30
|
+
it_should_print_column 'Controller'
|
31
|
+
it_should_print_column 'Search Query'
|
32
|
+
it_should_print_column 'Public'
|
33
|
+
it_should_print_column 'Owner Id'
|
34
|
+
it_should_print_column 'Owner Type'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'InfoCommand' do
|
39
|
+
let(:cmd) { HammerCLIForeman::Bookmark::InfoCommand.new('', ctx) }
|
40
|
+
|
41
|
+
context 'parameters' do
|
42
|
+
it_should_accept 'id', ['--id=1']
|
43
|
+
it_should_accept 'name', ['--name=active']
|
44
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
45
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'output' do
|
49
|
+
with_params ['--id=1'] do
|
50
|
+
it_should_print_n_records 1
|
51
|
+
it_should_print_column 'Id'
|
52
|
+
it_should_print_column 'Name'
|
53
|
+
it_should_print_column 'Controller'
|
54
|
+
it_should_print_column 'Search Query'
|
55
|
+
it_should_print_column 'Public'
|
56
|
+
it_should_print_column 'Owner Id'
|
57
|
+
it_should_print_column 'Owner Type'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'CreateCommand' do
|
63
|
+
let(:cmd) { HammerCLIForeman::Bookmark::CreateCommand.new('', ctx) }
|
64
|
+
|
65
|
+
context 'parameters' do
|
66
|
+
it_should_accept 'name, public, controller, query',
|
67
|
+
['--name=active', '--public=1', '--controller=hosts',
|
68
|
+
'--query=last_report > "35 minutes ago" and (status.applied > 0 or status.restarted > 0)']
|
69
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
70
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'DeleteCommand' do
|
76
|
+
let(:cmd) { HammerCLIForeman::Bookmark::DeleteCommand.new('', ctx) }
|
77
|
+
|
78
|
+
context 'parameters' do
|
79
|
+
it_should_accept 'id', ['--id=1']
|
80
|
+
it_should_accept 'name', ['--name=active']
|
81
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
82
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'UpdateCommand' do
|
87
|
+
let(:cmd) { HammerCLIForeman::Bookmark::UpdateCommand.new('', ctx) }
|
88
|
+
|
89
|
+
context 'parameters' do
|
90
|
+
it_should_accept 'id', ['--id=1']
|
91
|
+
it_should_accept 'name', ['--name=active']
|
92
|
+
it_should_accept 'name, public, controller, query',
|
93
|
+
['--name=active', '--public=1', '--controller=hosts',
|
94
|
+
'--query=last_report > "35 minutes ago" and (status.applied > 0 or status.restarted > 0)']
|
95
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
96
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/test/unit/commands_test.rb
CHANGED
@@ -19,16 +19,16 @@ describe HammerCLIForeman do
|
|
19
19
|
]
|
20
20
|
|
21
21
|
set = HammerCLIForeman.collection_to_common_format(old_format)
|
22
|
-
set.must_be_kind_of HammerCLI::Output::RecordCollection
|
23
|
-
set.first.must_equal(kind)
|
22
|
+
_(set).must_be_kind_of HammerCLI::Output::RecordCollection
|
23
|
+
_(set.first).must_equal(kind)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should convert common API format" do
|
27
27
|
common_format = [ kind ]
|
28
28
|
|
29
29
|
set = HammerCLIForeman.collection_to_common_format(common_format)
|
30
|
-
set.must_be_kind_of HammerCLI::Output::RecordCollection
|
31
|
-
set.first.must_equal(kind)
|
30
|
+
_(set).must_be_kind_of HammerCLI::Output::RecordCollection
|
31
|
+
_(set.first).must_equal(kind)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should convert new API format" do
|
@@ -46,12 +46,12 @@ describe HammerCLIForeman do
|
|
46
46
|
}
|
47
47
|
|
48
48
|
set = HammerCLIForeman.collection_to_common_format(new_format)
|
49
|
-
set.must_be_kind_of HammerCLI::Output::RecordCollection
|
50
|
-
set.first.must_equal(kind)
|
49
|
+
_(set).must_be_kind_of HammerCLI::Output::RecordCollection
|
50
|
+
_(set.first).must_equal(kind)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should rise error on unexpected format" do
|
54
|
-
proc { HammerCLIForeman.collection_to_common_format('unexpected') }.must_raise RuntimeError
|
54
|
+
_(proc { HammerCLIForeman.collection_to_common_format('unexpected') }).must_raise RuntimeError
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
@@ -67,14 +67,14 @@ describe HammerCLIForeman do
|
|
67
67
|
}
|
68
68
|
|
69
69
|
rec = HammerCLIForeman.record_to_common_format(old_format)
|
70
|
-
rec.must_equal(arch)
|
70
|
+
_(rec).must_equal(arch)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should convert common API format" do
|
74
74
|
common_format = arch
|
75
75
|
|
76
76
|
rec = HammerCLIForeman.record_to_common_format(common_format)
|
77
|
-
rec.must_equal(arch)
|
77
|
+
_(rec).must_equal(arch)
|
78
78
|
|
79
79
|
end
|
80
80
|
end
|
@@ -92,7 +92,7 @@ describe HammerCLIForeman do
|
|
92
92
|
})
|
93
93
|
arch = HammerCLIForeman::Architecture::CreateCommand.new("", { :adapter => :csv, :interactive => false })
|
94
94
|
out, err = capture_io { arch.run(["--name='i386'"]) }
|
95
|
-
out.must_match("Message,Id,Name\nArchitecture created.,3,i386\n")
|
95
|
+
_(out).must_match("Message,Id,Name\nArchitecture created.,3,i386\n")
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -111,7 +111,7 @@ describe HammerCLIForeman do
|
|
111
111
|
res.stubs(:get_identifier).returns(1)
|
112
112
|
res.stubs(:get_associated_identifier).returns(1)
|
113
113
|
|
114
|
-
res.get_new_ids.sort.must_equal ['1', '2']
|
114
|
+
_(res.get_new_ids.sort).must_equal ['1', '2']
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should associate resource with new format" do
|
@@ -128,7 +128,7 @@ describe HammerCLIForeman do
|
|
128
128
|
res.stubs(:get_identifier).returns(1)
|
129
129
|
res.stubs(:get_associated_identifier).returns(1)
|
130
130
|
|
131
|
-
res.get_new_ids.sort.must_equal ['1', '2']
|
131
|
+
_(res.get_new_ids.sort).must_equal ['1', '2']
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -152,7 +152,7 @@ describe HammerCLIForeman do
|
|
152
152
|
end
|
153
153
|
comm = DomainOuter::HostsCommand.new("", { :adapter => :csv, :interactive => false })
|
154
154
|
out, err = capture_io { comm.run(["--id=5"]) }
|
155
|
-
out.must_equal "Id,Name,Operating System,Host Group,IP,MAC\n2,random-host,,,192.168.100.112,6e:4b:3c:2c:8a:0a\n"
|
155
|
+
_(out).must_equal "Id,Name,Operating System,Host Group,IP,MAC\n2,random-host,,,192.168.100.112,6e:4b:3c:2c:8a:0a\n"
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -163,7 +163,7 @@ describe HammerCLIForeman::Command do
|
|
163
163
|
|
164
164
|
it "uses foreman option builder" do
|
165
165
|
builder = HammerCLIForeman::Command.option_builder
|
166
|
-
builder.class.must_equal HammerCLIForeman::ForemanOptionBuilder
|
166
|
+
_(builder.class).must_equal HammerCLIForeman::ForemanOptionBuilder
|
167
167
|
end
|
168
168
|
|
169
169
|
it "properly raises error on intentional searching of parameters that are not required" do
|
@@ -181,9 +181,9 @@ describe HammerCLIForeman::Command do
|
|
181
181
|
)
|
182
182
|
)
|
183
183
|
out, err = capture_io do
|
184
|
-
com.run(['--location', 'loc']).wont_equal HammerCLI::EX_OK
|
184
|
+
_(com.run(['--location', 'loc'])).wont_equal HammerCLI::EX_OK
|
185
185
|
end
|
186
|
-
err.must_equal "Error: Could not find location, please set one of options --location, --location-title, --location-id.\n"
|
186
|
+
_(err).must_equal "Error: Could not find location, please set one of options --location, --location-title, --location-id.\n"
|
187
187
|
|
188
188
|
end
|
189
189
|
|
@@ -205,7 +205,7 @@ describe HammerCLIForeman::Command do
|
|
205
205
|
ResourceMocks.mock_action_call(:domains, :index, [])
|
206
206
|
|
207
207
|
out, err = capture_io do
|
208
|
-
com.run([]).must_equal HammerCLI::EX_OK
|
208
|
+
_(com.run([])).must_equal HammerCLI::EX_OK
|
209
209
|
end
|
210
210
|
|
211
211
|
end
|
@@ -213,7 +213,7 @@ describe HammerCLIForeman::Command do
|
|
213
213
|
describe "build_options" do
|
214
214
|
it "uses build parameters in the block" do
|
215
215
|
HammerCLIForeman::Command.build_options do |o|
|
216
|
-
o.class.must_equal HammerCLIForeman::BuildParams
|
216
|
+
_(o.class).must_equal HammerCLIForeman::BuildParams
|
217
217
|
end
|
218
218
|
end
|
219
219
|
end
|
@@ -228,6 +228,6 @@ describe HammerCLIForeman::ListCommand do
|
|
228
228
|
it 'formats enum values in search fields help' do
|
229
229
|
search_field = { name: 'managed', values: [true, false] }
|
230
230
|
expected_output = 'Values: true, false'
|
231
|
-
OpenListCommand.new({}).search_field_help_value(search_field).must_equal(expected_output)
|
231
|
+
_(OpenListCommand.new({}).search_field_help_value(search_field)).must_equal(expected_output)
|
232
232
|
end
|
233
233
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
4
|
+
require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
5
|
+
|
6
|
+
require 'hammer_cli_foreman/compute_profile'
|
7
|
+
|
8
|
+
describe HammerCLIForeman::ComputeProfile do
|
9
|
+
include CommandTestHelper
|
10
|
+
|
11
|
+
context 'ListCommand' do
|
12
|
+
before :each do
|
13
|
+
ResourceMocks.compute_profiles
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:cmd) { HammerCLIForeman::ComputeProfile::ListCommand.new('', ctx) }
|
17
|
+
|
18
|
+
context 'parameters' do
|
19
|
+
it_should_accept 'no arguments'
|
20
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
21
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'output' do
|
25
|
+
let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
|
26
|
+
|
27
|
+
it_should_print_n_records
|
28
|
+
it_should_print_column 'Id'
|
29
|
+
it_should_print_column 'Name'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'InfoCommand' do
|
34
|
+
let(:cmd) { HammerCLIForeman::ComputeProfile::InfoCommand.new('', ctx) }
|
35
|
+
|
36
|
+
context 'parameters' do
|
37
|
+
it_should_accept 'id', ['--id=1']
|
38
|
+
it_should_accept 'name', ['--name=test']
|
39
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
40
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'output' do
|
44
|
+
with_params ['--id=1'] do
|
45
|
+
it_should_print_n_records 1
|
46
|
+
it_should_print_column 'Id'
|
47
|
+
it_should_print_column 'Name'
|
48
|
+
it_should_print_column 'Created at'
|
49
|
+
it_should_print_column 'Updated at'
|
50
|
+
it_should_print_column 'Compute attributes'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'CreateCommand' do
|
56
|
+
let(:cmd) { HammerCLIForeman::ComputeProfile::CreateCommand.new('', ctx) }
|
57
|
+
|
58
|
+
context 'parameters' do
|
59
|
+
it_should_accept 'name', ['--name=test']
|
60
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
61
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'DeleteCommand' do
|
67
|
+
let(:cmd) { HammerCLIForeman::ComputeProfile::DeleteCommand.new('', ctx) }
|
68
|
+
|
69
|
+
context 'parameters' do
|
70
|
+
it_should_accept 'id', ['--id=1']
|
71
|
+
it_should_accept 'name', ['--name=test']
|
72
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
73
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'UpdateCommand' do
|
78
|
+
let(:cmd) { HammerCLIForeman::ComputeProfile::UpdateCommand.new('', ctx) }
|
79
|
+
|
80
|
+
context 'parameters' do
|
81
|
+
it_should_accept 'id', ['--id=1']
|
82
|
+
it_should_accept 'name', ['--name=test']
|
83
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
84
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|