Skip to content

Add tests for docker:save multi-image feature and fix docker.save.aliases#1922

Open
JamBalaya56562 wants to merge 1 commit into
fabric8io:masterfrom
JamBalaya56562:save-coverage
Open

Add tests for docker:save multi-image feature and fix docker.save.aliases#1922
JamBalaya56562 wants to merge 1 commit into
fabric8io:masterfrom
JamBalaya56562:save-coverage

Conversation

@JamBalaya56562

Copy link
Copy Markdown
Contributor

Why

The SonarCloud Quality Gate on master is failing on Coverage on New Code (70.8% < 80%). The build/test CI is all green — the gap is new code from the docker:save multi-image feature (saveNames / saveAliases) that was merged without unit tests, plus one branch of the Docker 29+ IPAddress parsing in ContainerDetails.

This PR backfills unit tests for those paths and fixes a small bug found while doing so.

Tests added

  • UrlBuilderTest.getImagesimages/get?names=…&names=… URL building for multiple images (covers the getImages(List<ImageName>) method and the array-query-parameter support in build()).
  • DockerAccessWithHcClientTest.testSaveImages / testSaveImagesFail — the multi-image saveImages(...) happy path and the DockerAccessException wrapping on I/O failure.
  • SaveMojoTest (7 tests) — the parameter-conflict validation branches (name/alias vs. name-list/alias-list) and the "image(s) not found by name/alias" paths.
  • ContainerDetailsTest.testGetIPAddressNewFormatWithoutIpgetIPAddress() returns null when NetworkSettings.Networks is present but no network carries an IP.

Bug fix

SaveMojo.getSaveAliasesPendingToSave() had a copy/paste error: when docker.save.aliases was non-empty it returned the list without adding the aliases (the sibling getSaveNamesPendingToSave() correctly does addAll). As a result a non-existent alias in docker.save.aliases was silently ignored instead of failing the save with a clear "Can not find images with alias" error. Fixed to exit.addAll(saveAliases); the new SaveMojoTest.saveWithNonExistentAliases locks in the corrected behaviour.

Verification

  • Affected classes: green (UrlBuilderTest, DockerAccessWithHcClientTest, SaveMojoTest, ContainerDetailsTest).
  • Full unit-test suite green (943 tests, 0 failures).
  • No production behaviour change other than the docker.save.aliases validation fix.

🤖 Generated with Claude Code

@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@JamBalaya56562 JamBalaya56562 force-pushed the save-coverage branch 2 times, most recently from 013a57e to 20f6776 Compare July 5, 2026 08:44
…ases

Backfill unit-test coverage for the docker:save multi-image support
(saveNames/saveAliases) which shipped without tests, plus the Docker 29+
IPAddress parsing branch in ContainerDetails.

New tests:
- UrlBuilderTest.getImages: images/get URL with repeated "names" params
- DockerAccessWithHcClientTest.saveImages / saveImagesFail
- SaveMojoTest: parameter-conflict validation and image-not-found paths
- ContainerDetailsTest: getIPAddress returns null when no network carries an IP

Also fixes a copy/paste bug in SaveMojo.getSaveAliasesPendingToSave(): the
docker.save.aliases list was returned without being added, so a non-existent
alias in the list was silently ignored instead of failing the save.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant