Skip to content

Commit

Permalink
Fixes #27508 - use LCE for package list (#689)
Browse files Browse the repository at this point in the history
* Fixes #27508 - use LCE for package list

'hammer package list --environment=Library --organization-id=1'

This commit ensures that the --environment flag correctly points to
the lifecyle environment and not puppet env.

* Refs #27508 - Adds unit test

(cherry picked from commit 0b0b878)
  • Loading branch information
parthaa authored and chris1984 committed Aug 29, 2019
1 parent 5040606 commit b319d74
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/hammer_cli_katello/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ class PackageCommand < HammerCLIKatello::Command
resource :packages

class ListCommand < HammerCLIKatello::ListCommand
extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
include LifecycleEnvironmentNameMapping

output do
field :id, _("ID")
field :filename, _("Filename")
Expand Down Expand Up @@ -34,7 +37,6 @@ class ListCommand < HammerCLIKatello::ListCommand
:option_environment_name).required
end
end

build_options do |o|
o.expand.including(:products, :content_views)
end
Expand Down
25 changes: 25 additions & 0 deletions test/functional/package/list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
require_relative '../repository/repository_helpers'
require_relative '../product/product_helpers'
require_relative '../organization/organization_helpers'
require_relative '../lifecycle_environment/lifecycle_environment_helpers'
require 'hammer_cli_katello/package'

# rubocop:disable ModuleLength
module HammerCLIKatello
describe PackageCommand::ListCommand do
include OrganizationHelpers
include LifecycleEnvironmentHelpers
include RepositoryHelpers
include ProductHelpers

Expand Down Expand Up @@ -66,6 +69,28 @@ module HammerCLIKatello
end
end

describe 'environment options' do
it 'may be specified environment name' do
org_id = 2
env_name = "dev"
expected_id = 6
expect_lifecycle_environment_search(org_id, env_name, expected_id)

api_expects(:packages, :index).with_params("organization_id" => org_id,
"environment_id" => expected_id,
"page" => 1, "per_page" => 1000)

run_cmd(%W(package list --environment=#{env_name} --organization-id=#{org_id}))
end

it 'may be specified environment name no org fails' do
api_expects_no_call
r = run_cmd(%w(package list --environment Library))
expected_error = "--organization, --organization-label, --organization-id"
assert(r.err.include?(expected_error), "Invalid error message")
end
end

describe 'product options' do
it 'may be specified by ID' do
api_expects(:repositories, :index)
Expand Down

0 comments on commit b319d74

Please sign in to comment.