hammer_cli_katello 1.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,166 +0,0 @@
1
- # rubocop:disable Metrics/ModuleLength
2
- module HammerCLIKatello
3
- module CVImportExportHelper
4
- PUBLISHED_REPOS_DIR = "/var/lib/pulp/published/yum/https/repos/".freeze
5
-
6
- def fetch_exportable_cvv_repositories(cvv)
7
- immediate = []
8
- non_immediate_names = []
9
-
10
- cvv['repositories'].each do |repo|
11
- next unless repo['content_type'] == 'yum'
12
-
13
- api_repo = show(:repositories, 'id' => repo['id'], :full_result => true)
14
-
15
- download_policy = if api_repo['library_instance_id']
16
- library = show(:repositories, 'id' => api_repo['library_instance_id'])
17
- library['download_policy']
18
- else
19
- api_repo['download_policy']
20
- end
21
-
22
- if download_policy == 'immediate'
23
- immediate << api_repo
24
- else
25
- non_immediate_names << api_repo['name']
26
- end
27
- end
28
-
29
- warn_repo_download_policy(non_immediate_names)
30
-
31
- return immediate
32
- end
33
-
34
- def find_local_component_id(component_from_export)
35
- *name, version = component_from_export.split(' ')
36
- name = name.join(' ')
37
- existing_component_cv = content_view(name, options['option_organization_id'])
38
- found_composite_version = existing_component_cv['versions'].select do |v|
39
- v['version'] == version
40
- end
41
- if found_composite_version.empty?
42
- raise _("Unable to find CV version %{cvv} on system. Please ensure it " \
43
- "is already imported." % {'cvv' => component_from_export})
44
- end
45
- found_composite_version.first['id']
46
- end
47
-
48
- def warn_repo_download_policy(repository_names)
49
- return if repository_names.empty?
50
-
51
- msg = <<~MSG
52
- The following repositories could not be exported due to the download policy
53
- not being set to 'immediate':
54
- #{repository_names.join(', ')}
55
- MSG
56
- print_message msg
57
- end
58
-
59
- def collect_packages(repositories)
60
- repositories.each do |repo|
61
- per_page = 50
62
- repo['packages'] = []
63
- repo['errata'] = []
64
- repo_packages = repo['content_counts']['rpm']
65
- errata_count = repo['content_counts']['erratum']
66
- pkg_pages = (repo_packages / per_page.to_f).ceil
67
- errata_pages = (errata_count / per_page.to_f).ceil
68
- (1..pkg_pages).each do |page|
69
- repo['packages'] += index(:packages, 'repository_id' => repo['id'],
70
- :page => page, :per_page => 50)
71
- end
72
- (1..errata_pages).each do |page|
73
- repo['errata'] += index(:errata, 'repository_id' => repo['id'],
74
- :page => page, :per_page => 50)
75
- end
76
- end
77
- end
78
-
79
- def import_checks(cv, import_cv, major, minor)
80
- version = "#{major}.#{minor}".to_f
81
-
82
- if import_cv.nil?
83
- raise _("The Content View #{cv['name']} is not present on this server,"\
84
- " please create the Content View and try the import again.")
85
- end
86
-
87
- unless import_cv['default']
88
- if import_cv['latest_version'].to_f >= version
89
- raise _("The latest version (#{import_cv['latest_version']}) of"\
90
- " the Content View '#{cv['name']}'"\
91
- " is greater or equal to the version you are trying to import (#{version})")
92
- end
93
- end
94
-
95
- unless import_cv['repository_ids'].nil?
96
- repositories = import_cv['repository_ids'].collect do |repo_id|
97
- show(:repositories, 'id' => repo_id)
98
- end
99
- repositories.each do |repo|
100
- if repo['mirror_on_sync'] == true
101
- raise _("The Repository '#{repo['name']}' is set with Mirror-on-Sync to YES."\
102
- " Please change Mirror-on-Sync to NO and try the import again.")
103
- end
104
- end
105
- end
106
- end
107
-
108
- def untar_export(options)
109
- export_tar_file = options[:filename]
110
- export_tar_dir = options[:dirname]
111
- export_tar_prefix = options[:prefix]
112
-
113
- Dir.chdir(export_tar_dir) do
114
- `tar -xf #{export_tar_file}`
115
- end
116
-
117
- Dir.chdir("#{export_tar_dir}/#{export_tar_prefix}") do
118
- if File.exist?(export_tar_file.gsub('.tar', '-repos.tar'))
119
- `tar -xf #{export_tar_file.gsub('.tar', '-repos.tar')}`
120
- end
121
- end
122
- end
123
-
124
- def obtain_export_params(option_export_tar)
125
- export_tar_file = File.basename(option_export_tar)
126
- {:filename => export_tar_file,
127
- :dirname => File.dirname(option_export_tar),
128
- :prefix => export_tar_file.gsub('.tar', '')}
129
- end
130
-
131
- def read_json(options)
132
- export_tar_file = options[:filename]
133
- export_tar_dir = options[:dirname]
134
- export_tar_prefix = options[:prefix]
135
-
136
- json_file = export_tar_file.gsub('tar', 'json')
137
- json_file = "#{export_tar_dir}/#{export_tar_prefix}/#{json_file}"
138
- json_file = File.read(json_file)
139
- JSON.parse(json_file)
140
- end
141
-
142
- def export_json(export_json_options)
143
- content_view_version = export_json_options[:cvv]
144
- repositories = export_json_options[:repositories]
145
- json = {
146
- "name" => content_view_version['content_view']['name'],
147
- "major" => content_view_version['major'],
148
- "minor" => content_view_version['minor']
149
- }
150
- json["composite_components"] = export_json_options[:component_cvvs]
151
- json["repositories"] = repositories.collect do |repo|
152
- {
153
- "id" => repo['id'],
154
- "label" => repo['label'],
155
- "content_type" => repo['content_type'],
156
- "backend_identifier" => repo['backend_identifier'],
157
- "relative_path" => repo['relative_path'],
158
- "on_disk_path" => "#{PUBLISHED_REPOS_DIR}/#{repo['relative_path']}",
159
- "rpm_filenames" => repo['packages'].collect { |package| package['filename'] },
160
- "errata_ids" => repo['errata'].collect { |errata| errata['errata_id'] }
161
- }
162
- end
163
- json
164
- end
165
- end
166
- end
@@ -1,40 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
-
3
- describe 'content-view version export' do
4
- include ForemanTaskHelpers
5
-
6
- before do
7
- @cmd = %w(content-view version export-default)
8
- end
9
-
10
- it "performs export with bad SELinux" do
11
- params = [
12
- '--export-dir=/tmp/default'
13
- ]
14
-
15
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
16
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
17
-
18
- Dir.expects(:mkdir).with('/tmp/default').returns(0)
19
- Kernel.expects(:system).with("rsync -aL /var/lib/pulp/published/yum/https/repos/ /tmp/default")
20
-
21
- result = run_cmd(@cmd + params)
22
- assert_equal(HammerCLI::EX_CANTCREAT, result.exit_code)
23
- end
24
-
25
- it "performs export" do
26
- params = [
27
- '--export-dir=/tmp/default'
28
- ]
29
-
30
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
31
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
32
-
33
- Dir.expects(:exist?).with('/tmp/default').returns(0)
34
- Kernel.expects(:system).with("rsync -aL /var/lib/pulp/published/yum/https/repos/ /tmp/default")
35
- .returns(true)
36
-
37
- result = run_cmd(@cmd + params)
38
- assert_equal(HammerCLI::EX_OK, result.exit_code)
39
- end
40
- end
@@ -1,136 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
-
3
- describe 'content-view version export' do
4
- include ForemanTaskHelpers
5
-
6
- before do
7
- @cmd = %w(content-view version export)
8
- end
9
-
10
- it "performs export" do
11
- params = [
12
- '--id=5',
13
- '--export-dir=/tmp/exports'
14
- ]
15
-
16
- ex = api_expects(:content_view_versions, :show)
17
- ex.returns(
18
- 'id' => '5',
19
- 'repositories' => [{'id' => '2', 'content_type' => 'yum'}],
20
- 'major' => 1,
21
- 'minor' => 0,
22
- 'content_view' => {'name' => 'cv'},
23
- 'content_view_id' => 4321
24
- )
25
-
26
- ex = api_expects(:content_views, :show)
27
- ex.returns(
28
- 'id' => '4321',
29
- 'composite' => false,
30
- 'label' => 'cv'
31
- )
32
-
33
- ex = api_expects(:repositories, :show).with_params('id' => '2')
34
- ex.returns(
35
- 'id' => '2',
36
- 'label' => 'Test_Repo',
37
- 'content_type' => 'yum',
38
- 'download_policy' => 'immediate',
39
- 'backend_identifier' => 'Default_Organization-Library-Test_Repo',
40
- 'relative_path' => 'Default_Organization/Library/Test_Repo',
41
- 'library_instance_id' => '1',
42
- 'content_counts' => {
43
- 'rpm' => 1,
44
- 'erratum' => 1
45
- }
46
- )
47
-
48
- api_expects(:repositories, :show).with_params('id' => '1').returns(
49
- 'id' => '1',
50
- 'download_policy' => 'immediate'
51
- )
52
- api_expects(:packages, :index).returns('results' => [])
53
- api_expects(:errata, :index).returns('results' => [])
54
-
55
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
56
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
57
-
58
- Dir.expects(:chdir).with("/var/lib/pulp/published/yum/https/repos/").returns(true)
59
- Dir.expects(:mkdir).with('/tmp/exports/export-cv-1.0').returns(0)
60
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
61
- Dir.expects(:chdir).with('/tmp/exports/export-cv-1.0').returns(0)
62
-
63
- result = run_cmd(@cmd + params)
64
- assert_equal(HammerCLI::EX_OK, result.exit_code)
65
- end
66
-
67
- it "performs composite export" do
68
- params = [
69
- '--id=999',
70
- '--export-dir=/tmp/exports'
71
- ]
72
-
73
- ex = api_expects(:content_view_versions, :show)
74
- ex.returns(
75
- 'id' => '999',
76
- 'repositories' => [{'id' => '2'}],
77
- 'major' => 1,
78
- 'minor' => 0,
79
- 'content_view' => {'name' => 'cv'},
80
- 'content_view_id' => 4321
81
- )
82
-
83
- ex = api_expects(:content_views, :show)
84
- ex.returns(
85
- 'id' => '4321',
86
- 'composite' => true,
87
- 'components' => [{ 'name' => "injera 95.5" }, {'name' => 'carrot wot 87.0'}],
88
- 'label' => 'cv'
89
- )
90
-
91
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
92
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
93
-
94
- Dir.expects(:chdir).with("/var/lib/pulp/published/yum/https/repos/").never
95
- Dir.expects(:mkdir).with('/tmp/exports/export-cv-1.0').returns(0)
96
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
97
- Dir.expects(:chdir).with('/tmp/exports/export-cv-1.0').returns(0)
98
-
99
- result = run_cmd(@cmd + params)
100
- assert_equal(HammerCLI::EX_OK, result.exit_code)
101
- end
102
-
103
- it "fails export if content view version has no repository" do
104
- params = [
105
- '--id=5',
106
- '--export-dir=/tmp/exports'
107
- ]
108
-
109
- ex = api_expects(:content_view_versions, :show)
110
- ex.returns(
111
- 'id' => '5',
112
- 'name' => 'Test_version',
113
- 'repositories' => [],
114
- 'major' => 1,
115
- 'minor' => 0,
116
- 'content_view' => {'name' => 'cv'},
117
- 'content_view_id' => 4321,
118
- 'puppet_modules' => []
119
- )
120
-
121
- ex = api_expects(:content_views, :show)
122
- ex.returns(
123
- 'id' => '4321',
124
- 'composite' => false
125
- )
126
-
127
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
128
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
129
-
130
- result = run_cmd(@cmd + params)
131
- assert_equal(result.err, "Could not export the content view:\n"\
132
- " Error: Ensure the content view version 'Test_version'"\
133
- " has at least one repository.\n")
134
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
135
- end
136
- end
@@ -1,318 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
-
3
- describe 'content-view version import' do
4
- include ForemanTaskHelpers
5
-
6
- before do
7
- @cmd = %w(content-view version import)
8
- end
9
-
10
- it "performs import" do
11
- params = [
12
- '--export-tar=/tmp/exports/export-2.tar',
13
- '--organization-id=1'
14
- ]
15
-
16
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
17
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
18
-
19
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
20
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
21
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
22
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
23
- JSON.dump(
24
- 'name' => 'Foo View',
25
- 'major' => '5',
26
- 'minor' => '0',
27
- 'repositories' => [{
28
- 'label' => 'foo',
29
- 'rpm_filenames' => ['foo-1.0-1.el7']
30
- }]
31
- )
32
- )
33
-
34
- ex = api_expects(:content_views, :index)
35
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
36
- ex.returns(
37
- 'results' => [{
38
- 'id' => '5',
39
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
40
- 'content_view' => {'name' => 'cv'}
41
- }]
42
- )
43
-
44
- ex = api_expects(:repositories, :index)
45
- ex = ex.with_params('organization_id' => '1', 'library' => true)
46
- ex.returns(
47
- 'results' => [{
48
- 'id' => '2',
49
- 'label' => 'foo'
50
- }]
51
- )
52
-
53
- ex = api_expects(:repositories, :sync)
54
- ex = ex.with_params('id' => '2', 'source_url' => "file:///tmp/exports/export-2/")
55
- ex.returns('id' => '2', 'state' => 'planned')
56
-
57
- expect_foreman_task('3')
58
-
59
- ex = api_expects(:content_views, :publish)
60
- ex = ex.with_params(
61
- 'id' => '5',
62
- 'major' => '5',
63
- 'minor' => '0',
64
- 'repos_units' => [{
65
- 'label' => 'foo',
66
- 'rpm_filenames' => ['foo-1.0-1.el7']
67
- }]
68
- )
69
- ex.returns('id' => '2', 'state' => 'planned')
70
-
71
- expect_foreman_task('3')
72
-
73
- result = run_cmd(@cmd + params)
74
- assert_equal(HammerCLI::EX_OK, result.exit_code)
75
- end
76
-
77
- it "performs composite import" do
78
- params = [
79
- '--export-tar=/tmp/exports/export-999.tar',
80
- '--organization-id=1'
81
- ]
82
-
83
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
84
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
85
-
86
- File.expects(:exist?).with("/tmp/exports/export-999.tar").returns(true)
87
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
88
- Dir.expects(:chdir).with('/tmp/exports/export-999').returns(0)
89
- File.expects(:read).with("/tmp/exports/export-999/export-999.json").returns(
90
- JSON.dump(
91
- 'name' => 'Foo Composite View',
92
- 'major' => '10',
93
- 'minor' => '0',
94
- 'composite_components' => ["berbere 55.32"]
95
- )
96
- )
97
-
98
- ex = api_expects(:content_views, :index)
99
- ex = ex.with_params('name' => 'berbere', 'organization_id' => '1')
100
- ex.returns(
101
- 'results' => [{'versions' => [{'version' => '10.0', 'id' => '654'},
102
- {'version' => '55.32', 'id' => '876'}]
103
- }]
104
- )
105
-
106
- ex = api_expects(:content_views, :index)
107
- ex = ex.with_params('name' => 'Foo Composite View', 'organization_id' => '1')
108
- ex.returns(
109
- 'results' => [{
110
- 'id' => '5',
111
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
112
- 'content_view' => {'name' => 'cv'}
113
- }]
114
- )
115
-
116
- ex = api_expects(:content_views, :update)
117
- ex = ex.with_params(
118
- 'id' => '5',
119
- 'component_ids' => ['876']
120
- )
121
- ex.returns('id' => '5', 'state' => 'planned')
122
-
123
- ex = api_expects(:content_views, :publish)
124
- ex = ex.with_params(
125
- 'id' => '5',
126
- 'major' => '10',
127
- 'minor' => '0'
128
- )
129
- ex.returns('id' => '2', 'state' => 'planned')
130
-
131
- expect_foreman_task('3')
132
-
133
- result = run_cmd(@cmd + params)
134
- assert_equal(HammerCLI::EX_OK, result.exit_code)
135
- end
136
-
137
- it "performs composite import, component not found" do
138
- params = [
139
- '--export-tar=/tmp/exports/export-999.tar',
140
- '--organization-id=1'
141
- ]
142
-
143
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
144
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
145
-
146
- File.expects(:exist?).with("/tmp/exports/export-999.tar").returns(true)
147
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
148
- Dir.expects(:chdir).with('/tmp/exports/export-999').returns(0)
149
- File.expects(:read).with("/tmp/exports/export-999/export-999.json").returns(
150
- JSON.dump(
151
- 'name' => 'Foo Composite View',
152
- 'major' => '10',
153
- 'minor' => '0',
154
- 'composite_components' => ["berbere 55.32", "unicorn 99.99"]
155
- )
156
- )
157
-
158
- ex = api_expects(:content_views, :index)
159
- ex = ex.with_params('name' => 'berbere', 'organization_id' => '1')
160
- ex.returns(
161
- 'results' => [{'versions' => [{'version' => '10.0', 'id' => '654'},
162
- {'version' => '55.32', 'id' => '876'}]
163
- }]
164
- )
165
-
166
- ex = api_expects(:content_views, :index)
167
- ex = ex.with_params('name' => 'unicorn', 'organization_id' => '1')
168
- ex.returns(
169
- 'results' => []
170
- )
171
-
172
- ex = api_expects(:content_views, :index)
173
- ex = ex.with_params('name' => 'Foo Composite View', 'organization_id' => '1')
174
- ex.returns(
175
- 'results' => [{
176
- 'id' => '5',
177
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
178
- 'content_view' => {'name' => 'cv'}
179
- }]
180
- )
181
-
182
- result = run_cmd(@cmd + params)
183
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
184
- end
185
-
186
- it "fails import if cv has not been created" do
187
- params = [
188
- '--export-tar=/tmp/exports/export-2.tar',
189
- '--organization-id=1'
190
- ]
191
-
192
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
193
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
194
-
195
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
196
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
197
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
198
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
199
- JSON.dump(
200
- 'name' => 'Foo View'
201
- )
202
- )
203
-
204
- ex = api_expects(:content_views, :index)
205
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
206
- ex.returns([])
207
-
208
- result = run_cmd(@cmd + params)
209
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
210
- end
211
-
212
- it "fails import if repo is set to mirror-on-sync" do
213
- params = [
214
- '--export-tar=/tmp/exports/export-2.tar',
215
- '--organization-id=1'
216
- ]
217
-
218
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
219
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
220
-
221
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
222
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
223
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
224
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
225
- JSON.dump(
226
- 'name' => 'Foo View',
227
- 'major' => '2',
228
- 'minor' => '1'
229
- )
230
- )
231
-
232
- ex = api_expects(:content_views, :index)
233
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
234
- ex.returns(
235
- 'results' => [{
236
- 'id' => '5',
237
- 'repositories' => [{'id' => '2', 'label' => 'foo', 'mirror_on_sync' => 'true'}],
238
- 'content_view' => {'name' => 'cv'}
239
- }]
240
- )
241
-
242
- result = run_cmd(@cmd + params)
243
- assert_equal(result.exit_code, 70)
244
- end
245
-
246
- it "fails import if cv version already exists" do
247
- params = [
248
- '--export-tar=/tmp/exports/export-2.tar',
249
- '--organization-id=1'
250
- ]
251
-
252
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
253
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
254
-
255
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
256
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
257
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
258
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
259
- JSON.dump(
260
- 'name' => 'Foo View',
261
- 'major' => '2',
262
- 'minor' => '1'
263
- )
264
- )
265
-
266
- ex = api_expects(:content_views, :index)
267
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
268
- ex.returns(
269
- 'results' => [{
270
- 'id' => '5',
271
- 'content_view' => {'name' => 'cv'},
272
- 'versions' => [{'version' => '2.1', 'id' => '654'}]
273
- }]
274
- )
275
-
276
- result = run_cmd(@cmd + params)
277
- assert_equal(result.exit_code, 70)
278
- end
279
-
280
- it "fails import if any repository does not exist" do
281
- params = [
282
- '--export-tar=/tmp/exports/export-2.tar',
283
- '--organization-id=1'
284
- ]
285
-
286
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
287
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
288
-
289
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
290
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
291
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
292
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
293
- JSON.dump(
294
- 'name' => 'Foo View',
295
- 'repositories' => ['label' => 'foo'],
296
- 'major' => '2',
297
- 'minor' => '1'
298
- )
299
- )
300
-
301
- ex = api_expects(:content_views, :index)
302
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
303
- ex.returns(
304
- 'results' => [{
305
- 'id' => '5',
306
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
307
- 'content_view' => {'name' => 'cv'}
308
- }]
309
- )
310
-
311
- ex = api_expects(:repositories, :index)
312
- ex = ex.with_params('organization_id' => '1', 'library' => true)
313
- ex.returns([])
314
-
315
- result = run_cmd(@cmd + params)
316
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
317
- end
318
- end