diff --git a/lib/hammer_cli_katello/capsule.rb b/lib/hammer_cli_katello/capsule.rb index 6f620f50..a66b3ac4 100644 --- a/lib/hammer_cli_katello/capsule.rb +++ b/lib/hammer_cli_katello/capsule.rb @@ -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| diff --git a/test/functional/capsule/content/data/sync_status_no_counts.json b/test/functional/capsule/content/data/sync_status_no_counts.json new file mode 100644 index 00000000..28ca1490 --- /dev/null +++ b/test/functional/capsule/content/data/sync_status_no_counts.json @@ -0,0 +1,6 @@ +{ + "last_sync_time": "2016-01-10 00:27:51 +0100", + "active_sync_tasks": [], + "last_failed_sync_tasks": [], + "lifecycle_environments": [] +} diff --git a/test/functional/capsule/content/info_test.rb b/test/functional/capsule/content/info_test.rb index f1b63c86..13f7fced 100644 --- a/test/functional/capsule/content/info_test.rb +++ b/test/functional/capsule/content/info_test.rb @@ -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']