hammer_cli_katello 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello.rb +1 -0
- data/lib/hammer_cli_katello/content_view.rb +1 -1
- data/lib/hammer_cli_katello/filter.rb +19 -0
- data/lib/hammer_cli_katello/filter_rule.rb +0 -10
- data/lib/hammer_cli_katello/host_extensions.rb +2 -0
- data/lib/hammer_cli_katello/id_name_options_validator.rb +73 -0
- data/lib/hammer_cli_katello/package.rb +2 -0
- data/lib/hammer_cli_katello/repository.rb +17 -5
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/functional/content_view/create_test.rb +0 -3
- data/test/functional/content_view/filter/delete_test.rb +93 -0
- data/test/functional/content_view/filter/info_test.rb +92 -0
- data/test/functional/content_view/filter/list_test.rb +98 -0
- data/test/functional/content_view/filter/update_test.rb +93 -0
- data/test/functional/filter_rule/create_test.rb +0 -79
- data/test/functional/host/extensions/data/host.json +4 -2
- data/test/functional/host/extensions/info_test.rb +3 -1
- data/test/functional/lifecycle_environment/create_test.rb +14 -0
- data/test/functional/lifecycle_environment/list_test.rb +38 -0
- data/test/functional/lifecycle_environment/update_test.rb +14 -0
- data/test/functional/organization/organization_helpers.rb +2 -2
- data/test/functional/package/list_test.rb +48 -0
- data/test/functional/repository/delete_test.rb +101 -0
- data/test/functional/repository/upload_test.rb +43 -0
- data/test/unit/id_name_options_validator_test.rb +96 -0
- metadata +26 -13
- data/test/functional/filter_rule/delete_test.rb +0 -104
- data/test/functional/filter_rule/info_test.rb +0 -104
- data/test/functional/filter_rule/list_test.rb +0 -91
- data/test/functional/filter_rule/update_test.rb +0 -104
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../content_view_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__), '../../organization/organization_helpers')
|
4
|
+
|
5
|
+
describe 'listing content view filters' do
|
6
|
+
include ContentViewHelpers
|
7
|
+
include OrganizationHelpers
|
8
|
+
|
9
|
+
before do
|
10
|
+
@cmd = %w(content-view filter list)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:org_id) { 1 }
|
14
|
+
let(:org_label) { 'Ubik' }
|
15
|
+
let(:cv_name) { "Trystero" }
|
16
|
+
let(:empty_response) do
|
17
|
+
{
|
18
|
+
"total" => 0,
|
19
|
+
"subtotal" => 0,
|
20
|
+
"page" => "1",
|
21
|
+
"per_page" => "1000",
|
22
|
+
"error" => nil,
|
23
|
+
"search" => nil,
|
24
|
+
"sort" => {
|
25
|
+
"by" => nil,
|
26
|
+
"order" => nil
|
27
|
+
},
|
28
|
+
"results" => []
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
it "lists content view filters" do
|
33
|
+
params = ["--content-view-id=1"]
|
34
|
+
|
35
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
36
|
+
par['content_view_id'] == 1 && par['page'] == 1 && par['per_page'] == 1000
|
37
|
+
end
|
38
|
+
ex.returns(empty_response)
|
39
|
+
|
40
|
+
expected_result = success_result("----------|------|------|----------
|
41
|
+
FILTER ID | NAME | TYPE | INCLUSION
|
42
|
+
----------|------|------|----------
|
43
|
+
")
|
44
|
+
|
45
|
+
result = run_cmd(@cmd + params)
|
46
|
+
assert_cmd(expected_result, result)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "lists content view filters for a content view name and org id" do
|
50
|
+
params = ["--organization-id=#{org_id}", "--content-view=#{cv_name}"]
|
51
|
+
|
52
|
+
expect_content_view_search(org_id.to_s, cv_name, 1)
|
53
|
+
|
54
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
55
|
+
par['content_view_id'] == 1 && par['page'] == 1 && par['per_page'] == 1000
|
56
|
+
end
|
57
|
+
ex.returns(empty_response)
|
58
|
+
|
59
|
+
expected_result = success_result("----------|------|------|----------
|
60
|
+
FILTER ID | NAME | TYPE | INCLUSION
|
61
|
+
----------|------|------|----------
|
62
|
+
")
|
63
|
+
|
64
|
+
result = run_cmd(@cmd + params)
|
65
|
+
assert_cmd(expected_result, result)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "lists content view filters for a content view name and org label" do
|
69
|
+
params = ["--organization-label=#{org_label}", "--content-view=#{cv_name}"]
|
70
|
+
|
71
|
+
expect_organization_search(org_label, org_id, field: 'label')
|
72
|
+
expect_content_view_search(org_id, cv_name, 1)
|
73
|
+
|
74
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
75
|
+
par['content_view_id'] == 1 && par['page'] == 1 && par['per_page'] == 1000
|
76
|
+
end
|
77
|
+
ex.returns(empty_response)
|
78
|
+
|
79
|
+
expected_result = success_result("----------|------|------|----------
|
80
|
+
FILTER ID | NAME | TYPE | INCLUSION
|
81
|
+
----------|------|------|----------
|
82
|
+
")
|
83
|
+
|
84
|
+
result = run_cmd(@cmd + params)
|
85
|
+
assert_cmd(expected_result, result)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'requires org name, label, or id if content view name is supplied' do
|
89
|
+
params = ["--content-view=#{cv_name}"]
|
90
|
+
expected_result = usage_error_result(
|
91
|
+
@cmd,
|
92
|
+
'At least one of options --organization-id, --organization, --organization-label is required'
|
93
|
+
)
|
94
|
+
api_expects_no_call
|
95
|
+
result = run_cmd(@cmd + params)
|
96
|
+
assert_cmd(expected_result, result)
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../content_view_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__), '../../organization/organization_helpers')
|
4
|
+
|
5
|
+
module HammerCLIForeman
|
6
|
+
describe UpdateCommand do
|
7
|
+
include ContentViewHelpers
|
8
|
+
include OrganizationHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(content-view filter update)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'accepts filter id' do
|
15
|
+
params = ['--id=1', '--new-name=valis']
|
16
|
+
|
17
|
+
api_expects(:content_view_filters, :update) do |par|
|
18
|
+
par['id'] == '1' && par['name'] == 'valis'
|
19
|
+
end
|
20
|
+
|
21
|
+
run_cmd(@cmd + params)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'accepts filter name, content view name, and org name' do
|
25
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization=pkd', '--new-name=ubik']
|
26
|
+
|
27
|
+
expect_organization_search('pkd', 1)
|
28
|
+
expect_content_view_search(1, 'darkly', 1)
|
29
|
+
expect_content_view_search(1, 'darkly', 1) # redmine #15930
|
30
|
+
|
31
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
32
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
33
|
+
end
|
34
|
+
ex.returns(index_response([{'id' => '1'}]))
|
35
|
+
|
36
|
+
api_expects(:content_view_filters, :update) do |par|
|
37
|
+
par['id'] == '1' && par['name'] == 'ubik'
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(@cmd + params)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'accepts filter name, content view name, and org label' do
|
44
|
+
params = ['--name=scanner', '--content-view=darkly',
|
45
|
+
'--organization-label=pkd', '--new-name=ubik']
|
46
|
+
|
47
|
+
expect_organization_search('pkd', 1, field: 'label')
|
48
|
+
expect_content_view_search(1, 'darkly', 1)
|
49
|
+
expect_content_view_search(1, 'darkly', 1) # redmine #15930
|
50
|
+
|
51
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
52
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
53
|
+
end
|
54
|
+
ex.returns(index_response([{'id' => '1'}]))
|
55
|
+
|
56
|
+
api_expects(:content_view_filters, :update) do |par|
|
57
|
+
par['id'] == '1' && par['name'] == 'ubik'
|
58
|
+
end
|
59
|
+
|
60
|
+
run_cmd(@cmd + params)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'accepts filter name, content view name, and org id' do
|
64
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization-id=1', '--new-name=ubik']
|
65
|
+
|
66
|
+
expect_content_view_search('1', 'darkly', 1)
|
67
|
+
expect_content_view_search('1', 'darkly', 1) # redmine #15930
|
68
|
+
|
69
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
70
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
71
|
+
end
|
72
|
+
ex.returns(index_response([{'id' => '1'}]))
|
73
|
+
|
74
|
+
api_expects(:content_view_filters, :update) do |par|
|
75
|
+
par['id'] == '1' && par['name'] == 'ubik'
|
76
|
+
end
|
77
|
+
|
78
|
+
run_cmd(@cmd + params)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'requires content view name or id if name is supplied' do
|
82
|
+
params = ["--name=high-castle"]
|
83
|
+
expected_result = usage_error_result(
|
84
|
+
@cmd,
|
85
|
+
'At least one of options --content-view-id, --content-view is required',
|
86
|
+
'Could not update the filter'
|
87
|
+
)
|
88
|
+
api_expects_no_call
|
89
|
+
result = run_cmd(@cmd + params)
|
90
|
+
assert_cmd(expected_result, result)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -16,84 +16,5 @@ module HammerCLIKatello
|
|
16
16
|
end
|
17
17
|
run_cmd(%w(content-view filter rule create --content-view-filter-id 1 --names rpm1,rpm2))
|
18
18
|
end
|
19
|
-
|
20
|
-
it 'allows name resolution of filter with content-view-id' do
|
21
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
22
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
23
|
-
end
|
24
|
-
ex.returns(index_response([{'id' => 1}]))
|
25
|
-
|
26
|
-
api_expects(:content_view_filter_rules, :create) do |p|
|
27
|
-
p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
|
28
|
-
end
|
29
|
-
run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --content-view-id 3
|
30
|
-
--name rule9))
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'organization' do
|
34
|
-
it 'ID can be specified to resolve content view name' do
|
35
|
-
ex = api_expects(:content_views, :index) do |p|
|
36
|
-
p['name'] == 'cv3' && p['organization_id'] == '6'
|
37
|
-
end
|
38
|
-
ex.returns(index_response([{'id' => 3}]))
|
39
|
-
|
40
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
41
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
42
|
-
end
|
43
|
-
ex.returns(index_response([{'id' => 1}]))
|
44
|
-
|
45
|
-
api_expects(:content_view_filter_rules, :create) do |p|
|
46
|
-
p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
|
47
|
-
end
|
48
|
-
run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization-id 6
|
49
|
-
--content-view cv3 --name rule9))
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'name can be specified to resolve content view name' do
|
53
|
-
ex = api_expects(:organizations, :index) do |p|
|
54
|
-
p[:search] == "name = \"org6\""
|
55
|
-
end
|
56
|
-
ex.returns(index_response([{'id' => 6}]))
|
57
|
-
|
58
|
-
ex = api_expects(:content_views, :index) do |p|
|
59
|
-
p['name'] == 'cv3' && p['organization_id'] == 6
|
60
|
-
end
|
61
|
-
ex.returns(index_response([{'id' => 3}]))
|
62
|
-
|
63
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
64
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
65
|
-
end
|
66
|
-
ex.returns(index_response([{'id' => 1}]))
|
67
|
-
|
68
|
-
api_expects(:content_view_filter_rules, :create) do |p|
|
69
|
-
p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
|
70
|
-
end
|
71
|
-
run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization org6
|
72
|
-
--content-view cv3 --name rule9))
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'label can be specified to resolve content view name' do
|
76
|
-
ex = api_expects(:organizations, :index) do |p|
|
77
|
-
p[:search] == "label = \"org6\""
|
78
|
-
end
|
79
|
-
ex.returns(index_response([{'id' => 6}]))
|
80
|
-
|
81
|
-
ex = api_expects(:content_views, :index) do |p|
|
82
|
-
p['name'] == 'cv3' && p['organization_id'] == 6
|
83
|
-
end
|
84
|
-
ex.returns(index_response([{'id' => 3}]))
|
85
|
-
|
86
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
87
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
88
|
-
end
|
89
|
-
ex.returns(index_response([{'id' => 1}]))
|
90
|
-
|
91
|
-
api_expects(:content_view_filter_rules, :create) do |p|
|
92
|
-
p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
|
93
|
-
end
|
94
|
-
run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization-label
|
95
|
-
org6 --content-view cv3 --name rule9))
|
96
|
-
end
|
97
|
-
end
|
98
19
|
end
|
99
20
|
end
|
@@ -92,7 +92,9 @@
|
|
92
92
|
"content_view_version_id":1,
|
93
93
|
"content_view_default?":true,
|
94
94
|
"lifecycle_environment_library?":true,
|
95
|
-
"katello_agent_installed":true
|
95
|
+
"katello_agent_installed":true,
|
96
|
+
"applicable_package_count": 5,
|
97
|
+
"upgradable_package_count": 4
|
96
98
|
},
|
97
99
|
"subscription_facet_attributes":{
|
98
100
|
"id":2,
|
@@ -307,4 +309,4 @@
|
|
307
309
|
"ipmi_boot":true,
|
308
310
|
"puppetrun_hosts":true
|
309
311
|
}
|
310
|
-
}
|
312
|
+
}
|
@@ -20,7 +20,9 @@ describe 'host info' do
|
|
20
20
|
['Content View', 'Default Organization View'],
|
21
21
|
['Release Version', '7Server'],
|
22
22
|
['Bug Fix', '0'],
|
23
|
-
['Name', 'my host collection']
|
23
|
+
['Name', 'my host collection'],
|
24
|
+
['Applicable Packages', '5'],
|
25
|
+
['Upgradable Packages', '4']]
|
24
26
|
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
|
25
27
|
expected_results.each { |expected| assert_cmd(expected, result) }
|
26
28
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/lifecycle_environment'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe LifecycleEnvironmentCommand::CreateCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:lifecycle_environments, :create) do |p|
|
8
|
+
p['name'] == 'le1' && p['prior_id'] == '3' && p['organization_id'] == 1
|
9
|
+
end
|
10
|
+
|
11
|
+
run_cmd(%w(lifecycle-environment create --name le1 --prior-id 3 --organization-id 1))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/lifecycle_environment'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe LifecycleEnvironmentCommand::ListCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:lifecycle_environments, :index)
|
8
|
+
|
9
|
+
run_cmd(%w(lifecycle-environment list))
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'allows organization' do
|
13
|
+
it 'id' do
|
14
|
+
api_expects(:lifecycle_environments, :index) { |p| p['organization_id'] == 1 }
|
15
|
+
|
16
|
+
run_cmd(%w(lifecycle-environment list --organization-id 1))
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'name' do
|
20
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
21
|
+
.at_least_once.returns(index_response([{'id' => 1}]))
|
22
|
+
|
23
|
+
api_expects(:lifecycle_environments, :index) { |p| p['organization_id'] == 1 }
|
24
|
+
|
25
|
+
run_cmd(%w(lifecycle-environment list --organization org1))
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'label' do
|
29
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
30
|
+
.at_least_once.returns(index_response([{'id' => 1}]))
|
31
|
+
|
32
|
+
api_expects(:lifecycle_environments, :index) { |p| p['organization_id'] == 1 }
|
33
|
+
|
34
|
+
run_cmd(%w(lifecycle-environment list --organization-label org1))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/lifecycle_environment'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe LifecycleEnvironmentCommand::UpdateCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:lifecycle_environments, :update) do |p|
|
8
|
+
p['new_name'] == 'le3' && p['id'] == 3
|
9
|
+
end
|
10
|
+
|
11
|
+
run_cmd(%w(lifecycle-environment update --id 3 --new-name le3))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module OrganizationHelpers
|
2
|
-
def expect_organization_search(
|
2
|
+
def expect_organization_search(name_or_label, id, field: 'name')
|
3
3
|
ex = api_expects(:organizations, :index, 'Find the organization') do |par|
|
4
|
-
par[:search] == "
|
4
|
+
par[:search] == "#{field} = \"#{name_or_label}\""
|
5
5
|
end
|
6
6
|
ex.at_least_once.returns(index_response([{'id' => id}]))
|
7
7
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/package'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe PackageCommand::ListCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:packages, :index)
|
8
|
+
|
9
|
+
run_cmd(%w(package list))
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'organization options' do
|
13
|
+
it 'can be provided by organization ID' do
|
14
|
+
api_expects(:packages, :index) do |params|
|
15
|
+
params['organization_id'] == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
run_cmd(%w(package list --organization-id 1))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'can be provided by organization name' do
|
22
|
+
ex = api_expects(:organizations, :index) do |params|
|
23
|
+
params[:search] == "name = \"org1\""
|
24
|
+
end
|
25
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
26
|
+
|
27
|
+
api_expects(:packages, :index) do |params|
|
28
|
+
params['organization_id'] == 1
|
29
|
+
end
|
30
|
+
|
31
|
+
run_cmd(%w(package list --organization org1))
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'can be provided by organization label' do
|
35
|
+
ex = api_expects(:organizations, :index) do |params|
|
36
|
+
params[:search] == "label = \"org1\""
|
37
|
+
end
|
38
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
39
|
+
|
40
|
+
api_expects(:packages, :index) do |params|
|
41
|
+
params['organization_id'] == 1
|
42
|
+
end
|
43
|
+
|
44
|
+
run_cmd(%w(package list --organization-label org1))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/repository'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe Repository::DeleteCommand do
|
6
|
+
it 'allows minimal parameters' do
|
7
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == '1' }
|
8
|
+
run_cmd(%w(repository delete --id 1))
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'product options' do
|
12
|
+
it 'are required to resolve repository name' do
|
13
|
+
api_expects_no_call
|
14
|
+
result = run_cmd(%w(repository delete --name repo1))
|
15
|
+
assert_includes(result.err, 'At least one of options --product, --product-id is required')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'can be specified via product id' do
|
19
|
+
ex = api_expects(:repositories, :index) do |p|
|
20
|
+
p['product_id'] == 3 && p['name'] == 'repo1'
|
21
|
+
end
|
22
|
+
ex.returns(index_response([{'id' => 1}]))
|
23
|
+
|
24
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
25
|
+
|
26
|
+
run_cmd(%w(repository delete --name repo1 --product-id 3))
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can be specified via product name' do
|
30
|
+
ex = api_expects(:products, :index) do |p|
|
31
|
+
p['organization_id'] == '6' && p['name'] == 'product3'
|
32
|
+
end
|
33
|
+
ex.returns(index_response([{'id' => 3}]))
|
34
|
+
|
35
|
+
ex = api_expects(:repositories, :index) do |p|
|
36
|
+
p['product_id'] == 3 && p['name'] == 'repo1' && p['organization_id'] == '6'
|
37
|
+
end
|
38
|
+
ex.returns(index_response([{'id' => 1}]))
|
39
|
+
|
40
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
41
|
+
|
42
|
+
run_cmd(%w(repository delete --name repo1 --product product3 --organization-id 6))
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'organization options' do
|
46
|
+
it 'can be specified by organization id' do
|
47
|
+
ex = api_expects(:repositories, :index) do |p|
|
48
|
+
p['product_id'] == 3 && p['name'] == 'repo1' && p['organization_id'] == '6'
|
49
|
+
end
|
50
|
+
ex.returns(index_response([{'id' => 1}]))
|
51
|
+
|
52
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
53
|
+
|
54
|
+
run_cmd(%w(repository delete --name repo1 --product-id 3 --organization-id 6))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'can be specified by organization name' do
|
58
|
+
ex = api_expects(:organizations, :index) do |p|
|
59
|
+
p[:search] == "name = \"org6\""
|
60
|
+
end
|
61
|
+
ex.returns(index_response([{'id' => 6}]))
|
62
|
+
|
63
|
+
ex = api_expects(:products, :index) do |p|
|
64
|
+
p['organization_id'] == 6 && p['name'] == 'product3'
|
65
|
+
end
|
66
|
+
ex.returns(index_response([{'id' => 3}]))
|
67
|
+
|
68
|
+
ex = api_expects(:repositories, :index) do |p|
|
69
|
+
p['product_id'] == 3 && p['name'] == 'repo1'
|
70
|
+
end
|
71
|
+
ex.returns(index_response([{'id' => 1}]))
|
72
|
+
|
73
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
74
|
+
|
75
|
+
run_cmd(%w(repository delete --name repo1 --product product3 --organization org6))
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'can be specified by organization label' do
|
79
|
+
ex = api_expects(:organizations, :index) do |p|
|
80
|
+
p[:search] == "label = \"org6\""
|
81
|
+
end
|
82
|
+
ex.returns(index_response([{'id' => 6}]))
|
83
|
+
|
84
|
+
ex = api_expects(:products, :index) do |p|
|
85
|
+
p['organization_id'] == 6 && p['name'] == 'product3'
|
86
|
+
end
|
87
|
+
ex.returns(index_response([{'id' => 3}]))
|
88
|
+
|
89
|
+
ex = api_expects(:repositories, :index) do |p|
|
90
|
+
p['product_id'] == 3 && p['name'] == 'repo1'
|
91
|
+
end
|
92
|
+
ex.returns(index_response([{'id' => 1}]))
|
93
|
+
|
94
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
95
|
+
|
96
|
+
run_cmd(%w(repository delete --name repo1 --product product3 --organization-label org6))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|