hammer_cli_katello 0.14.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/apipie_helper.rb +15 -0
  3. data/lib/hammer_cli_katello/associating_commands.rb +6 -2
  4. data/lib/hammer_cli_katello/commands.rb +7 -0
  5. data/lib/hammer_cli_katello/content_view_purge.rb +1 -1
  6. data/lib/hammer_cli_katello/content_view_version.rb +238 -2
  7. data/lib/hammer_cli_katello/erratum.rb +4 -0
  8. data/lib/hammer_cli_katello/file.rb +4 -6
  9. data/lib/hammer_cli_katello/foreman_search_options_creators.rb +1 -1
  10. data/lib/hammer_cli_katello/id_resolver.rb +2 -0
  11. data/lib/hammer_cli_katello/local_helper.rb +9 -0
  12. data/lib/hammer_cli_katello/module_stream.rb +69 -0
  13. data/lib/hammer_cli_katello/module_stream_profile.rb +0 -0
  14. data/lib/hammer_cli_katello/ostree_branch.rb +4 -0
  15. data/lib/hammer_cli_katello/package_group.rb +4 -0
  16. data/lib/hammer_cli_katello/puppet_module.rb +4 -0
  17. data/lib/hammer_cli_katello/repository.rb +21 -7
  18. data/lib/hammer_cli_katello/repository_scoped_to_product.rb +3 -3
  19. data/lib/hammer_cli_katello/search_options_creators.rb +10 -2
  20. data/lib/hammer_cli_katello/sync_plan.rb +6 -8
  21. data/lib/hammer_cli_katello/version.rb +1 -1
  22. data/lib/hammer_cli_katello.rb +9 -0
  23. data/test/data/3.8/foreman_api.json +1 -1
  24. data/test/data/3.9/foreman_api.json +1 -0
  25. data/test/functional/apipie_helper_test.rb +26 -0
  26. data/test/functional/content_view/publish_test.rb +20 -0
  27. data/test/functional/content_view/version/export_test.rb +87 -0
  28. data/test/functional/content_view/version/import_test.rb +111 -0
  29. data/test/functional/content_view/version/incremental_update_test.rb +0 -0
  30. data/test/functional/local_helper_test.rb +30 -0
  31. data/test/functional/module_stream/info_test.rb +58 -0
  32. data/test/functional/module_stream/list_test.rb +53 -0
  33. data/test/functional/package_group/list_test.rb +14 -9
  34. data/test/functional/sync_plan/create_test.rb +60 -0
  35. data/test/functional/sync_plan/delete_test.rb +46 -0
  36. data/test/functional/sync_plan/update_test.rb +44 -0
  37. data/test/test_helper.rb +1 -1
  38. data/test/unit/search_options_creators_test.rb +4 -1
  39. metadata +30 -9
@@ -0,0 +1,26 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper')
2
+
3
+ describe 'apipie helper' do
4
+ before do
5
+ class ApipieTestHelper
6
+ include HammerCLIKatello::ApipieHelper
7
+ end
8
+
9
+ @apipie_helper = ApipieTestHelper.new
10
+ end
11
+
12
+ it "calls show method apipie resource" do
13
+ api_expects(:repositories, :show).with_params('id' => '1').returns({})
14
+ assert @apipie_helper.show(:repositories, 'id' => '1')
15
+ end
16
+
17
+ it "calls index method apipie resource" do
18
+ api_expects(:repositories, :index).with_params('name' => 'foo').returns('results' => [])
19
+ assert @apipie_helper.index(:repositories, 'name' => 'foo')
20
+ end
21
+
22
+ it "call method for apipie resources works" do
23
+ api_expects(:repositories, :index).with_params('name' => 'foo').returns('results' => [])
24
+ assert @apipie_helper.call(:index, :repositories, 'name' => 'foo')
25
+ end
26
+ end
@@ -2,6 +2,26 @@ require_relative '../test_helper'
2
2
  require 'hammer_cli_katello/content_view_puppet_module'
3
3
 
4
4
  module HammerCLIKatello
5
+ describe ContentView do
6
+ it 'allows major & minor' do
7
+ ex = api_expects(:organizations, :index) do |p|
8
+ p[:search] == "name = \"org1\""
9
+ end
10
+ ex.returns(index_response([{'id' => 1}]))
11
+
12
+ ex = api_expects(:content_views, :index) do |p|
13
+ p['name'] == 'cv' && p['organization_id'] == 1
14
+ end
15
+ ex.returns(index_response([{'id' => 3}]))
16
+
17
+ api_expects(:content_views, :publish) do |p|
18
+ p['id'] == 3 && p['major'] == 5 && p['minor'] == 1
19
+ end
20
+
21
+ run_cmd(%w(content-view publish --major 5 --minor 1 --organization org1 --name cv --async))
22
+ end
23
+ end
24
+
5
25
  describe ContentViewPuppetModule do
6
26
  it 'allows adding a puppet module' do
7
27
  ex = api_expects(:organizations, :index) do |p|
@@ -0,0 +1,87 @@
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'}],
20
+ 'major' => 1,
21
+ 'minor' => 0,
22
+ 'content_view' => {'name' => 'cv'}
23
+ )
24
+
25
+ ex = api_expects(:repositories, :show).with_params('id' => '2')
26
+ ex.returns(
27
+ 'id' => '2',
28
+ 'label' => 'Test_Repo',
29
+ 'content_type' => 'yum',
30
+ 'backend_identifier' => 'Default_Organization-Library-Test_Repo',
31
+ 'relative_path' => 'Default_Organization/Library/Test_Repo',
32
+ 'library_instance_id' => '1'
33
+ )
34
+
35
+ api_expects(:repositories, :show).with_params('id' => '1').returns(
36
+ 'id' => '1',
37
+ 'download_policy' => 'immediate'
38
+ )
39
+ api_expects(:packages, :index).returns('results' => [])
40
+ api_expects(:errata, :index).returns('results' => [])
41
+
42
+ File.expects(:exist?).with('/usr/share/foreman').returns(true)
43
+ Dir.expects(:chdir).with("/var/lib/pulp/published/yum/https/repos/").returns(true)
44
+ Dir.expects(:mkdir).with('/tmp/exports/export-5').returns(0)
45
+ Dir.expects(:chdir).with('/tmp/exports').returns(0)
46
+ Dir.expects(:chdir).with('/tmp/exports/export-5').returns(0)
47
+
48
+ result = run_cmd(@cmd + params)
49
+ assert_equal(HammerCLI::EX_OK, result.exit_code)
50
+ end
51
+
52
+ it "fails export if any repository is set to on_demand" do
53
+ params = [
54
+ '--id=5',
55
+ '--export-dir=/tmp/exports'
56
+ ]
57
+
58
+ ex = api_expects(:content_view_versions, :show)
59
+ ex.returns(
60
+ 'id' => '5',
61
+ 'repositories' => [{'id' => '2'}],
62
+ 'major' => 1,
63
+ 'minor' => 0,
64
+ 'content_view' => {'name' => 'cv'}
65
+ )
66
+
67
+ ex = api_expects(:repositories, :show).with_params('id' => '2')
68
+ ex.returns(
69
+ 'id' => '2',
70
+ 'label' => 'Test_Repo',
71
+ 'content_type' => 'yum',
72
+ 'backend_identifier' => 'Default_Organization-Library-Test_Repo',
73
+ 'relative_path' => 'Default_Organization/Library/Test_Repo',
74
+ 'library_instance_id' => '1'
75
+ )
76
+
77
+ api_expects(:repositories, :show).with_params('id' => '1').returns(
78
+ 'id' => '1',
79
+ 'download_policy' => 'on_demand'
80
+ )
81
+
82
+ File.expects(:exist?).with('/usr/share/foreman').returns(true)
83
+
84
+ result = run_cmd(@cmd + params)
85
+ assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
86
+ end
87
+ end
@@ -0,0 +1,111 @@
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
+
18
+ File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
19
+ Dir.expects(:chdir).with('/tmp/exports').returns(0)
20
+ Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
21
+ File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
22
+ JSON.dump(
23
+ 'name' => 'Foo View',
24
+ 'major' => '5',
25
+ 'minor' => '0',
26
+ 'repositories' => [{
27
+ 'label' => 'foo',
28
+ 'rpm_filenames' => ['foo-1.0-1.el7']
29
+ }]
30
+ )
31
+ )
32
+
33
+ ex = api_expects(:content_views, :index)
34
+ ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
35
+ ex.returns(
36
+ 'results' => [{
37
+ 'id' => '5',
38
+ 'repositories' => [{'id' => '2', 'label' => 'foo'}],
39
+ 'content_view' => {'name' => 'cv'}
40
+ }]
41
+ )
42
+
43
+ ex = api_expects(:repositories, :index)
44
+ ex = ex.with_params('organization_id' => '1', 'library' => true)
45
+ ex.returns(
46
+ 'results' => [{
47
+ 'id' => '2',
48
+ 'label' => 'foo'
49
+ }]
50
+ )
51
+
52
+ ex = api_expects(:repositories, :sync)
53
+ ex = ex.with_params('id' => '2', 'source_url' => "file:///tmp/exports/export-2/")
54
+ ex.returns('id' => '2', 'state' => 'planned')
55
+
56
+ expect_foreman_task('3')
57
+
58
+ ex = api_expects(:content_views, :publish)
59
+ ex = ex.with_params(
60
+ 'id' => '5',
61
+ 'major' => '5',
62
+ 'minor' => '0',
63
+ 'repos_units' => [{
64
+ 'label' => 'foo',
65
+ 'rpm_filenames' => ['foo-1.0-1.el7']
66
+ }]
67
+ )
68
+ ex.returns('id' => '2', 'state' => 'planned')
69
+
70
+ expect_foreman_task('3')
71
+
72
+ result = run_cmd(@cmd + params)
73
+ assert_equal(HammerCLI::EX_OK, result.exit_code)
74
+ end
75
+
76
+ it "fails import if any repository does not exist" do
77
+ params = [
78
+ '--export-tar=/tmp/exports/export-2.tar',
79
+ '--organization-id=1'
80
+ ]
81
+
82
+ File.expects(:exist?).with('/usr/share/foreman').returns(true)
83
+
84
+ File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
85
+ Dir.expects(:chdir).with('/tmp/exports').returns(0)
86
+ Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
87
+ File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
88
+ JSON.dump(
89
+ 'name' => 'Foo View',
90
+ 'repositories' => ['label' => 'foo']
91
+ )
92
+ )
93
+
94
+ ex = api_expects(:content_views, :index)
95
+ ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
96
+ ex.returns(
97
+ 'results' => [{
98
+ 'id' => '5',
99
+ 'repositories' => [{'id' => '2', 'label' => 'foo'}],
100
+ 'content_view' => {'name' => 'cv'}
101
+ }]
102
+ )
103
+
104
+ ex = api_expects(:repositories, :index)
105
+ ex = ex.with_params('organization_id' => '1', 'library' => true)
106
+ ex.returns([])
107
+
108
+ result = run_cmd(@cmd + params)
109
+ assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
110
+ end
111
+ end
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper')
2
+
3
+ describe 'local helper' do
4
+ before do
5
+ class SuperLocalTestHelper
6
+ def parse_subcommand
7
+ true
8
+ end
9
+ end
10
+
11
+ class LocalTestHelper < SuperLocalTestHelper
12
+ include HammerCLIKatello::LocalHelper
13
+ end
14
+
15
+ @local_helper = LocalTestHelper.new
16
+ end
17
+
18
+ it "does not fail if /usr/share/foreman exists" do
19
+ File.expects(:exist?).with('/usr/share/foreman').returns(true)
20
+ assert @local_helper.parse_subcommand
21
+ end
22
+
23
+ it "fails if /usr/share/foreman does not exist" do
24
+ File.expects(:exist?).with('/usr/share/foreman').returns(false)
25
+
26
+ assert_raises RuntimeError do
27
+ @local_helper.parse_subcommand
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,58 @@
1
+ require_relative '../test_helper'
2
+ require 'hammer_cli_katello/module_stream'
3
+
4
+ module HammerCLIKatello
5
+ describe ModuleStreamCommand::InfoCommand do
6
+ it 'allows ID' do
7
+ api_expects(:module_streams, :show).with_params('id' => '1')
8
+
9
+ run_cmd(%w(module-stream info --id 1))
10
+ end
11
+
12
+ it 'resolves ID from name and repo id' do
13
+ api_expects(:module_streams, :index)
14
+ .with_params(search: "name = \"duck\"", name: "duck", repository_id: "1")
15
+ .returns(index_response([{'id' => 1}]))
16
+
17
+ api_expects(:module_streams, :show)
18
+ .with_params(repository_id: "1", id: 1)
19
+
20
+ run_cmd(%w(module-stream info --name duck --repository-id 1))
21
+ end
22
+
23
+ it 'resolves ID from name, repo name, and product id' do
24
+ api_expects(:module_streams, :index)
25
+ .with_params(search: "name = \"walrus\"")
26
+ .returns(index_response([{'id' => 1}]))
27
+
28
+ api_expects(:repositories, :index)
29
+ .with_params(name: 'zoo', product_id: 1)
30
+ .returns(index_response([{'id' => 1}]))
31
+
32
+ api_expects(:module_streams, :show)
33
+ .with_params(repository_id: 1, id: 1)
34
+
35
+ run_cmd(%w(module-stream info --name walrus --repository zoo --product-id 1))
36
+ end
37
+
38
+ it 'resolves ID from name, repo name, product name, and org id' do
39
+ api_expects(:products, :index)
40
+ .with_params(name: "habitat", organization_id: 1)
41
+ .returns(index_response([{'id' => 1}]))
42
+
43
+ api_expects(:module_streams, :index)
44
+ .with_params(search: "name = \"walrus\"")
45
+ .returns(index_response([{'id' => 1}]))
46
+
47
+ api_expects(:repositories, :index)
48
+ .with_params(name: 'zoo', product_id: 1)
49
+ .returns(index_response([{'id' => 1}]))
50
+
51
+ api_expects(:module_streams, :show)
52
+ .with_params(repository_id: 1, id: 1)
53
+
54
+ run_cmd(%w(module-stream info --name walrus --repository zoo
55
+ --product habitat --organization-id 1))
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,53 @@
1
+ require_relative '../test_helper'
2
+ require 'hammer_cli_katello/module_stream'
3
+
4
+ module HammerCLIKatello
5
+ describe ModuleStreamCommand::ListCommand do
6
+ it 'allows minimal options' do
7
+ api_expects(:module_streams, :index)
8
+
9
+ run_cmd(%w(module-stream list))
10
+ end
11
+
12
+ it 'can be provided by repository ID' do
13
+ api_expects(:module_streams, :index).with_params(repository_id: 1)
14
+
15
+ run_cmd(%w(module-stream list --repository-id 1))
16
+ end
17
+
18
+ it 'product params needed with repository name' do
19
+ cmd = run_cmd(%w(module-stream list --repository Repo))
20
+ error_msg = "At least one of options --product, --product-id is required."
21
+ api_expects_no_call
22
+ assert_match error_msg, cmd.err
23
+ end
24
+
25
+ it 'can be provided by repository name and product id' do
26
+ api_expects(:repositories, :index)
27
+ .with_params(name: "Repo", product_id: 1)
28
+ .returns(index_response([{'id' => 1}]))
29
+
30
+ api_expects(:module_streams, :index).with_params(repository_id: 1)
31
+
32
+ run_cmd(%w(module-stream list --repository Repo --product-id 1))
33
+ end
34
+
35
+ it 'can be provided by repository id and organization id' do
36
+ api_expects(:module_streams, :index)
37
+ .with_params(repository_id: 1, organization_id: 1)
38
+
39
+ run_cmd(%w(module-stream list --repository-id 1 --organization-id 1))
40
+ end
41
+
42
+ it 'can be provided by repository name, product id, and organization id' do
43
+ api_expects(:repositories, :index)
44
+ .with_params(name: "Repo", product_id: 1)
45
+ .returns(index_response([{'id' => 1}]))
46
+
47
+ api_expects(:module_streams, :index)
48
+ .with_params(repository_id: 1, organization_id: 1)
49
+
50
+ run_cmd(%w(module-stream list --repository Repo --product-id 1 --organization-id 1))
51
+ end
52
+ end
53
+ end
@@ -17,17 +17,22 @@ module HammerCLIKatello
17
17
  run_cmd(%w(package-group list --repository-id 1))
18
18
  end
19
19
 
20
- it 'can be provided by repository name' do
21
- ex = api_expects(:repositories, :index) do |params|
22
- params['name'] = 'Repo'
23
- end
24
- ex.returns(index_response([{'id' => 1}]))
20
+ it 'needs product options with repository name' do
21
+ cmd = run_cmd(%w(package-group list --repository Repo))
22
+ api_expects_no_call
23
+ error_msg = "At least one of options --product, --product-id is required."
24
+ assert_match error_msg, cmd.err
25
+ end
25
26
 
26
- api_expects(:package_groups, :index) do |params|
27
- params['repository_id'] == 1
28
- end
27
+ it 'can be provided product id and repository name' do
28
+ api_expects(:repositories, :index)
29
+ .with_params(name: "Repo", product_id: 1)
30
+ .returns(index_response([{'id' => 1}]))
31
+
32
+ api_expects(:package_groups, :index)
33
+ .with_params(repository_id: 1)
29
34
 
30
- run_cmd(%w(package-group list --repository Repo))
35
+ run_cmd(%w(package-group list --repository Repo --product-id 1))
31
36
  end
32
37
  end
33
38
  end
@@ -0,0 +1,60 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe "create sync plan" do
4
+ let(:org_id) { 1 }
5
+ let(:name) { "sync_plan1" }
6
+ let(:hourly) { "hourly" }
7
+ let(:custom) { "custom cron" }
8
+ let(:cron) { "10 * * * *" }
9
+ let(:date) { "2018-09-08T00:00:00+00:00" }
10
+
11
+ it 'with organization ID,name,interval,date and enabled' do
12
+ api_expects(:sync_plans, :create, 'create a sync plan').
13
+ with_params('organization_id' => org_id,
14
+ 'name' => name,
15
+ 'interval' => hourly,
16
+ 'sync_date' => date,
17
+ 'enabled' => true)
18
+ command = %W(sync-plan create --organization-id #{org_id} --name #{name}
19
+ --interval #{hourly} --enabled 1 --sync-date #{date})
20
+ assert_equal(0, run_cmd(command).exit_code)
21
+ end
22
+
23
+ it 'with custom cron' do
24
+ api_expects(:sync_plans, :create, 'create a sync plan').
25
+ with_params('organization_id' => org_id,
26
+ 'name' => name,
27
+ 'interval' => custom,
28
+ 'cron_expression' => cron,
29
+ 'sync_date' => date,
30
+ 'enabled' => true)
31
+ # end
32
+ command = %W(sync-plan create --organization-id #{org_id} --name #{name} --interval #{custom}
33
+ --cron-expression #{cron} --enabled 1 --sync-date #{date})
34
+ assert_equal(0, run_cmd(command).exit_code)
35
+ end
36
+
37
+ it 'fails without organization-id' do
38
+ command = %w(sync-plan create --name #{name}
39
+ --interval #{hourly} --enabled 1 --sync-date #{date})
40
+ refute_equal(0, run_cmd(command).exit_code)
41
+ end
42
+
43
+ it 'fails without name' do
44
+ command = %w(sync-plan create --organization-id #{org_id}
45
+ --interval #{hourly} --enabled 1 --sync-date #{date})
46
+ refute_equal(0, run_cmd(command).err)
47
+ end
48
+
49
+ it 'fails without interval' do
50
+ command = %w(sync-plan create --organization-id #{org_id} --name #{name}
51
+ --enabled 1 --sync-date #{date})
52
+ refute_equal(0, run_cmd(command).exit_code)
53
+ end
54
+
55
+ it 'fails without enabled' do
56
+ command = %w(sync-plan create --organization-id #{org_id} --name #{name}
57
+ --interval #{hourly} --sync-date #{date})
58
+ refute_equal(0, run_cmd(command).exit_code)
59
+ end
60
+ end
@@ -0,0 +1,46 @@
1
+ require_relative '../test_helper'
2
+ require_relative 'sync_plan_helpers'
3
+ require_relative '../organization/organization_helpers'
4
+
5
+ describe 'delete a sync plan' do
6
+ include OrganizationHelpers
7
+ include SyncPlanHelpers
8
+
9
+ let(:org_id) { 1 }
10
+ let(:id) { 1 }
11
+ let(:name) { "sync_plan1" }
12
+ let(:org_name) { "org1" }
13
+
14
+ it 'by organization ID and sync plan id' do
15
+ api_expects(:sync_plans, :destroy, 'delete a sync plan').
16
+ with_params('organization_id' => org_id,
17
+ 'id' => id)
18
+ command = %W(sync-plan delete --organization-id #{org_id} --id #{id})
19
+ assert_equal(0, run_cmd(command).exit_code)
20
+ end
21
+
22
+ it 'by organization ID and sync plan name' do
23
+ expect_sync_plan_search(1, 'sync_plan1', 1)
24
+ api_expects(:sync_plans, :destroy, 'delete a sync plan').
25
+ with_params('id' => id)
26
+ command = %W(sync-plan delete --organization-id #{org_id} --name #{name})
27
+ assert_equal(0, run_cmd(command).exit_code)
28
+ end
29
+
30
+ it 'by organization name and sync plan name' do
31
+ expect_organization_search('org1', 1)
32
+ expect_sync_plan_search(1, 'sync_plan1', 1)
33
+ api_expects(:sync_plans, :destroy, 'delete a sync plan').
34
+ with_params('id' => id)
35
+ command = %W(sync-plan delete --organization #{org_name} --name #{name})
36
+ assert_equal(0, run_cmd(command).exit_code)
37
+ end
38
+
39
+ it 'by organization name and sync plan id' do
40
+ expect_organization_search(org_name, org_id)
41
+ api_expects(:sync_plans, :destroy, 'delete a sync plan').
42
+ with_params('id' => id)
43
+ command = %W(sync-plan delete --organization #{org_name} --id #{id})
44
+ assert_equal(0, run_cmd(command).exit_code)
45
+ end
46
+ end
@@ -0,0 +1,44 @@
1
+ require_relative '../test_helper'
2
+ require_relative 'sync_plan_helpers'
3
+ require_relative '../organization/organization_helpers'
4
+
5
+ describe 'update a sync plan' do
6
+ include OrganizationHelpers
7
+ include SyncPlanHelpers
8
+
9
+ let(:org_id) { 1 }
10
+ let(:id) { 1 }
11
+ let(:name) { "sync_plan1" }
12
+ let(:org_name) { "org1" }
13
+ let(:desc) { "New Description" }
14
+
15
+ it 'with organization id and sync plan ID' do
16
+ api_expects(:sync_plans, :update, 'update a sync plan').
17
+ with_params('description' => desc,
18
+ 'id' => id)
19
+ command = %W(sync-plan update --organization-id #{org_id} --id #{id}
20
+ --description #{desc})
21
+ assert_equal(0, run_cmd(command).exit_code)
22
+ end
23
+
24
+ it 'with organization ID and sync plan name' do
25
+ expect_sync_plan_search(org_id, name, id)
26
+ api_expects(:sync_plans, :update, 'update a sync plan').
27
+ with_params('description' => desc,
28
+ 'id' => id)
29
+ command = %W(sync-plan update --organization-id #{org_id} --name #{name}
30
+ --description #{desc})
31
+ assert_equal(0, run_cmd(command).exit_code)
32
+ end
33
+
34
+ it 'with organization name and sync plan name' do
35
+ expect_organization_search(org_name, org_id)
36
+ expect_sync_plan_search(org_id, name, id)
37
+ api_expects(:sync_plans, :update, 'update a sync plan').
38
+ with_params('description' => desc,
39
+ 'id' => id)
40
+ command = %W(sync-plan update --organization #{org_name} --name #{name}
41
+ --description #{desc})
42
+ assert_equal(0, run_cmd(command).exit_code)
43
+ end
44
+ end
data/test/test_helper.rb CHANGED
@@ -17,7 +17,7 @@ require 'minitest/spec'
17
17
  require 'mocha/setup'
18
18
  require 'hammer_cli'
19
19
 
20
- KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '3.8')
20
+ KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '3.9')
21
21
 
22
22
  if HammerCLI.context[:api_connection]
23
23
  HammerCLI.context[:api_connection].create('foreman') do
@@ -118,9 +118,12 @@ describe HammerCLIKatello::SearchOptionsCreators do
118
118
  end # describe 'without the katello api'
119
119
 
120
120
  describe '#create_search_options_with_katello_api' do
121
+ let(:searchable1) { HammerCLIForeman::Searchable.new('one', '') }
122
+ let(:searchable2) { HammerCLIForeman::Searchable.new('two', '') }
123
+
121
124
  it 'translates all searchable fields from options' do
122
125
  search_options_creators.stubs(:searchables).
123
- returns([search_options_creators.method(:one), search_options_creators.method(:two)])
126
+ returns([searchable1, searchable2])
124
127
 
125
128
  search_options_creators.create_search_options_with_katello_api(
126
129
  {'option_one' => 1, 'option_two' => 2}, resource