Skip to content

Commit

Permalink
Fixes #37031 - hammer proxy content info fails when DB has no content…
Browse files Browse the repository at this point in the history
… counts
  • Loading branch information
ianballou committed Jan 11, 2024
1 parent e09be6e commit f1f7476
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hammer_cli_katello/capsule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def extend_data(data)
data["lifecycle_environments"].each do |lce|
lce["content_views"].each do |cv|
cv["repositories"].each do |repo|
if cv["up_to_date"]
if cv["up_to_date"] && !data.dig("content_counts").nil?
cvv_count_repos = data.dig("content_counts", "content_view_versions",
cv["cvv_id"].to_s, "repositories")
cvv_count_repos.each do |_repo_id, counts_and_metadata|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"last_sync_time": "2016-01-10 00:27:51 +0100",
"active_sync_tasks": [],
"last_failed_sync_tasks": [],
"lifecycle_environments": []
}
43 changes: 43 additions & 0 deletions test/functional/capsule/content/info_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,49 @@
assert_cmd(expected_result, result)
end

it "works with no content counts" do
@sync_status = load_json('./data/sync_status_no_counts.json', __FILE__)
@sync_status['lifecycle_environments'] = [
load_json('./data/library_env.json', __FILE__),
load_json('./data/unsynced_env.json', __FILE__)
]

ex = api_expects(:capsule_content, :sync_status, 'Get sync info') do |par|
par['id'] == 3
end
ex.returns(@sync_status)

output = OutputMatcher.new([
"Lifecycle Environments:",
" 1) Name: Library",
" Organization: Default Organization",
" Content Views:",
" 1) Name: Zoo View",
" Composite: no",
" Last Published: 2023/10/09 19:18:15",
" Repositories:",
" 1) Repository ID: 2",
" Repository Name: Zoo",
" Content Counts:",
" Warning: Content view must be synced to see content counts",
" 2) Name: Test",
" Organization: Default Organization",
" Content Views:",
" 1) Name: Zoo View",
" Composite: no",
" Last Published: 2023/10/09 19:18:15",
" Repositories:",
" 1) Repository ID: 2",
" Repository Name: Zoo",
" Content Counts:",
" Warning: Content view must be synced to see content counts"
])
expected_result = success_result(output)

result = run_cmd(@cmd + params)
assert_cmd(expected_result, result)
end

it "resolves id from name" do
params = ['--name=capsule1']

Expand Down

0 comments on commit f1f7476

Please sign in to comment.