diff --git a/tests/logs/push/test_push/test_push_item_no_destinations.jsonl b/tests/logs/push/test_push/test_push_item_no_destinations.jsonl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tests/logs/push/test_push/test_push_item_no_destinations.jsonl @@ -0,0 +1 @@ + diff --git a/tests/logs/push/test_push/test_push_item_no_destinations.txt b/tests/logs/push/test_push/test_push_item_no_destinations.txt new file mode 100644 index 0000000..8d69de4 --- /dev/null +++ b/tests/logs/push/test_push/test_push_item_no_destinations.txt @@ -0,0 +1,10 @@ +[ INFO] Loading items from koji:https://fakekoji.com?vmi_build=ami_build +[ INFO] Retrieving the mappings for ami_pushitem from https://starmap-example.com +[ INFO] starmap query returned for ami_pushitem : {"name": "test-build", "version": "7.0", "query_response": {"name": "fake-policy", "workflow": "stratosphere", "clouds": {"aws-na": []}}} +[ INFO] Filtering out archive with no destinations: None +[ INFO] Retrieving the mappings for vhd_pushitem from https://starmap-example.com +[ INFO] starmap query returned for vhd_pushitem : {"name": "test-build", "version": "7.0", "query_response": {"name": "fake-policy", "workflow": "stratosphere", "clouds": {"aws-na": []}}} +[ INFO] Filtering out archive with no destinations: None +[ INFO] Collecting results +[ ERROR] Marketplace VM push failed +# Raised: 30 diff --git a/tests/push/test_push.py b/tests/push/test_push.py index 9ace620..28ad99c 100644 --- a/tests/push/test_push.py +++ b/tests/push/test_push.py @@ -374,6 +374,38 @@ def test_push_item_no_mapped_arch( ) +@mock.patch("pubtools._marketplacesvm.tasks.push.MarketplacesVMPush.starmap") +def test_push_item_no_destinations( + mock_starmap: mock.MagicMock, + fake_source: mock.MagicMock, + fake_cloud_instance: mock.MagicMock, + ami_push_item: AmiPushItem, + command_tester: CommandTester, +) -> None: + """Ensure the push item with no destinations is filtered out.""" + qr = QueryResponse.from_json( + { + "name": "fake-policy", + "workflow": "stratosphere", + "mappings": {"aws-na": []}, + } + ) + mock_starmap.query_image_by_name.return_value = qr + + command_tester.test( + lambda: entry_point(MarketplacesVMPush), + [ + "test-push", + "--starmap-url", + "https://starmap-example.com", + "--credentials", + "eyJtYXJrZXRwbGFjZV9hY2NvdW50IjogInRlc3QtbmEiLCAiYXV0aCI6eyJmb28iOiJiYXIifQo=", + "--debug", + "koji:https://fakekoji.com?vmi_build=ami_build", + ], + ) + + @mock.patch("pubtools._marketplacesvm.tasks.push.MarketplacesVMPush.cloud_instance") def test_push_item_fail_upload( mock_cloud_instance: mock.MagicMock,