hammer_cli_foreman 2.3.0 → 2.5.1
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 +27 -0
- data/lib/hammer_cli_foreman.rb +3 -0
- data/lib/hammer_cli_foreman/architecture.rb +5 -5
- data/lib/hammer_cli_foreman/bookmark.rb +6 -6
- data/lib/hammer_cli_foreman/command_extensions.rb +1 -0
- data/lib/hammer_cli_foreman/command_extensions/ping.rb +21 -2
- data/lib/hammer_cli_foreman/command_extensions/status.rb +1 -1
- data/lib/hammer_cli_foreman/command_extensions/update_common.rb +14 -0
- data/lib/hammer_cli_foreman/commands.rb +14 -0
- data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
- data/lib/hammer_cli_foreman/compute_resource.rb +22 -0
- data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +2 -1
- data/lib/hammer_cli_foreman/config_group.rb +5 -5
- data/lib/hammer_cli_foreman/config_report.rb +2 -0
- data/lib/hammer_cli_foreman/filter.rb +2 -2
- data/lib/hammer_cli_foreman/host.rb +1 -11
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +6 -5
- 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/option_builders.rb +27 -7
- data/lib/hammer_cli_foreman/ping.rb +6 -1
- data/lib/hammer_cli_foreman/registration.rb +18 -0
- data/lib/hammer_cli_foreman/settings.rb +3 -3
- data/lib/hammer_cli_foreman/usergroup.rb +5 -5
- data/lib/hammer_cli_foreman/version.rb +1 -1
- 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/data/2.4/foreman_api.json +1 -0
- data/test/data/2.5/foreman_api.json +1 -0
- data/test/functional/architecture_test.rb +79 -0
- data/test/functional/bookmark_test.rb +22 -1
- data/test/functional/compute_profile_test.rb +54 -0
- data/test/functional/compute_resource_test.rb +37 -0
- data/test/functional/config_group_test.rb +50 -0
- data/test/functional/filter_test.rb +115 -47
- data/test/functional/host_test.rb +99 -3
- data/test/functional/http_proxy_test.rb +12 -0
- data/test/functional/location_test.rb +13 -0
- data/test/functional/mail_notification_test.rb +20 -0
- data/test/functional/media_test.rb +11 -0
- data/test/functional/model_test.rb +50 -0
- data/test/functional/operating_system_test.rb +51 -0
- data/test/functional/ping_test.rb +33 -0
- data/test/functional/realm_test.rb +11 -0
- data/test/functional/registration_test.rb +8 -0
- data/test/functional/report_template_test.rb +11 -0
- data/test/functional/settings_test.rb +21 -0
- data/test/functional/status_test.rb +79 -13
- data/test/functional/template_test.rb +12 -0
- data/test/functional/user_test.rb +11 -0
- data/test/functional/usergroup_test.rb +51 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/apipie_resource_mock.rb +21 -0
- data/test/unit/architecture_test.rb +10 -1
- data/test/unit/bookmark_test.rb +99 -0
- data/test/unit/compute_profile_test.rb +87 -0
- data/test/unit/config_group_test.rb +10 -0
- data/test/unit/config_report_test.rb +1 -0
- data/test/unit/host_test.rb +0 -23
- data/test/unit/mail_notification_test.rb +53 -0
- data/test/unit/model_test.rb +10 -0
- data/test/unit/operating_system_test.rb +14 -1
- data/test/unit/settings_test.rb +4 -0
- data/test/unit/usergroup_test.rb +10 -0
- metadata +129 -107
- data/test/reports/TEST-Minitest-Result.xml +0 -4344
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
4
|
+
|
5
|
+
describe 'user-group' do
|
6
|
+
describe 'list' do
|
7
|
+
before do
|
8
|
+
@cmd = %w[user-group list]
|
9
|
+
@user_groups = [{
|
10
|
+
id: 1,
|
11
|
+
name: 'test-user-group',
|
12
|
+
admin: 'yes',
|
13
|
+
}]
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return a list of user groups' do
|
17
|
+
api_expects(:usergroups, :index, 'List user groups').returns(@user_groups)
|
18
|
+
|
19
|
+
output = IndexMatcher.new([
|
20
|
+
%w[ID NAME ADMIN],
|
21
|
+
%w[1 test-user-group yes]
|
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(:usergroups, :index, 'List user groups').returns(@user_groups)
|
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
|
+
|
data/test/test_helper.rb
CHANGED
@@ -17,7 +17,7 @@ require "mocha/minitest"
|
|
17
17
|
require 'hammer_cli'
|
18
18
|
require 'hammer_cli_foreman/testing/api_expectations'
|
19
19
|
|
20
|
-
FOREMAN_VERSION = ENV['TEST_API_VERSION'] || '2.
|
20
|
+
FOREMAN_VERSION = ENV['TEST_API_VERSION'] || '2.5'
|
21
21
|
unless Dir.entries('test/data').include? FOREMAN_VERSION
|
22
22
|
raise StandardError.new "Version is not correct"
|
23
23
|
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
|
@@ -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
|
@@ -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
|
@@ -16,6 +16,8 @@ describe HammerCLIForeman::ConfigGroup do
|
|
16
16
|
context "parameters" do
|
17
17
|
it_should_accept "no arguments"
|
18
18
|
it_should_accept_search_params
|
19
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
20
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
19
21
|
end
|
20
22
|
|
21
23
|
context "output" do
|
@@ -31,6 +33,8 @@ describe HammerCLIForeman::ConfigGroup do
|
|
31
33
|
context "parameters" do
|
32
34
|
it_should_accept "id", ["--id=1"]
|
33
35
|
it_should_accept "name", ["--name=group_x"]
|
36
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
37
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
34
38
|
end
|
35
39
|
|
36
40
|
context "output" do
|
@@ -48,6 +52,8 @@ describe HammerCLIForeman::ConfigGroup do
|
|
48
52
|
|
49
53
|
context "parameters" do
|
50
54
|
it_should_accept "name, puppetclass ids", ["--name=first_group", "--puppet-class-ids=1,2"]
|
55
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
56
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
51
57
|
end
|
52
58
|
end
|
53
59
|
|
@@ -57,6 +63,8 @@ describe HammerCLIForeman::ConfigGroup do
|
|
57
63
|
context "parameters" do
|
58
64
|
it_should_accept "name", ["--name=group_x"]
|
59
65
|
it_should_accept "id", ["--id=1"]
|
66
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
67
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
@@ -67,6 +75,8 @@ describe HammerCLIForeman::ConfigGroup do
|
|
67
75
|
context "parameters" do
|
68
76
|
it_should_accept "name", ["--name=group_x"]
|
69
77
|
it_should_accept "id", ["--id=1"]
|
78
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
79
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
70
80
|
end
|
71
81
|
end
|
72
82
|
end
|
@@ -25,6 +25,7 @@ describe HammerCLIForeman::ConfigReport do
|
|
25
25
|
it_should_print_n_records
|
26
26
|
it_should_print_column "Id"
|
27
27
|
it_should_print_column "Host"
|
28
|
+
it_should_print_column "Origin"
|
28
29
|
it_should_print_column "Last report"
|
29
30
|
it_should_print_column "Applied"
|
30
31
|
it_should_print_column "Restarted"
|
data/test/unit/host_test.rb
CHANGED
@@ -132,29 +132,6 @@ describe HammerCLIForeman::Host do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
|
135
|
-
context "PuppetRunCommand" do
|
136
|
-
|
137
|
-
let(:cmd) { HammerCLIForeman::Host::PuppetRunCommand.new("", ctx) }
|
138
|
-
|
139
|
-
context "parameters" do
|
140
|
-
it_should_accept "name", ["--name=host"]
|
141
|
-
it_should_accept "id", ["--id=1"]
|
142
|
-
# it_should_fail_with "no arguments"
|
143
|
-
# TODO: temporarily disabled, parameters are checked in the id resolver
|
144
|
-
|
145
|
-
end
|
146
|
-
|
147
|
-
context "output" do
|
148
|
-
with_params ["--id=1"] do
|
149
|
-
it "should inform that puppet was triggered" do
|
150
|
-
cmd.stubs(:context).returns(ctx.update(:adapter => :test))
|
151
|
-
_(proc { cmd.run(with_params) }).must_output "Puppet run triggered\n"
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
135
|
context "ConfigReportsCommand" do
|
159
136
|
before do
|
160
137
|
ResourceMocks.mock_action_call(:config_reports, :index, [])
|
@@ -0,0 +1,53 @@
|
|
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/mail_notification'
|
7
|
+
|
8
|
+
describe HammerCLIForeman::MailNotification do
|
9
|
+
include CommandTestHelper
|
10
|
+
|
11
|
+
context 'ListCommand' do
|
12
|
+
before :each do
|
13
|
+
ResourceMocks.mail_notifications
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:cmd) { HammerCLIForeman::MailNotification::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::MailNotification::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 'Description'
|
49
|
+
it_should_print_column 'Subscription type'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|