Repository: GoogleContainerTools/jib
File: jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/PushImageStepTest.java (Java)

Code before:
    manifest.setSize(100);
    manifest.setDigest("sha256:1f25787aab4669d252bdae09a72b9c345d2a7b8c64c8dbfba4c82af4834dbccc");
    manifestList.addManifest(manifest);
  }

  @Test
  public void testMakeListForManifestList() throws IOException, RegistryException {
    ImmutableList<PushImageStep> pushImageStepList =
        PushImageStep.makeListForManifestList(
            buildContext, progressDispatcherFactory, registryClient, manifestList, false);

    Assert.assertEquals(2, pushImageStepList.size());
    for (PushImageStep pushImageStep : pushImageStepList) {
      BuildResult buildResult = pushImageStep.call();
      Assert.assertEquals(
          "sha256:64303e82b8a80ef20475dc7f807b81f172cacce1a59191927f3a7ea5222f38ae",
          buildResult.getImageDigest().toString());
      Assert.assertEquals(
          "sha256:64303e82b8a80ef20475dc7f807b81f172cacce1a59191927f3a7ea5222f38ae",
          buildResult.getImageId().toString());
    }
  }

  @Test
  public void testMakeList_multiPlatform_enabled() throws IOException, RegistryException {
    Image asd = Image.builder(V22ManifestTemplate.class).setArchitecture("wasm").build();

    Mockito.when(buildContext.isEnablePlatformTags()).thenReturn(true);

    ImmutableList<PushImageStep> pushImageStepList =
        PushImageStep.makeList(
            buildContext,
            progressDispatcherFactory,
            registryClient,
            new BlobDescriptor(mockDescriptorDigest),
            asd,
            false);

    ArgumentCaptor<String> tagCatcher = ArgumentCaptor.forClass(String.class);
    Mockito.when(registryClient.pushManifest(Mockito.any(), tagCatcher.capture())).thenReturn(null);

    Assert.assertEquals(2, pushImageStepList.size());
    pushImageStepList.get(0).call();
    pushImageStepList.get(1).call();

    assertThat(tagCatcher.getAllValues()).containsExactly("tag1-wasm", "tag2-wasm");
  }

  @Test
  public void testMakeList_multiPlatform_disabled() throws IOException, RegistryException {
    Image asd = Image.builder(V22ManifestTemplate.class).setArchitecture("wasm").build();

Review comment (suggestion):
```suggestion
    Image image = Image.builder(V22ManifestTemplate.class).setArchitecture("wasm").build();
```
or some name that reads better.

Code after:

    ManifestDescriptorTemplate manifest = new ManifestDescriptorTemplate();
    manifest.setSize(100);
    manifest.setDigest("sha256:1f25787aab4669d252bdae09a72b9c345d2a7b8c64c8dbfba4c82af4834dbccc");
    manifestList.addManifest(manifest);
  }

  @Test
  public void testMakeListForManifestList() throws IOException, RegistryException {
    List<PushImageStep> pushImageStepList =
        PushImageStep.makeListForManifestList(
            buildContext, progressDispatcherFactory, registryClient, manifestList, false);

    assertThat(pushImageStepList).hasSize(2);
    for (PushImageStep pushImageStep : pushImageStepList) {
      BuildResult buildResult = pushImageStep.call();
      assertThat(buildResult.getImageDigest().toString())
          .isEqualTo("sha256:64303e82b8a80ef20475dc7f807b81f172cacce1a59191927f3a7ea5222f38ae");
      assertThat(buildResult.getImageId().toString())
          .isEqualTo("sha256:64303e82b8a80ef20475dc7f807b81f172cacce1a59191927f3a7ea5222f38ae");
    }
  }

  @Test
  public void testMakeList_multiPlatform_platformTags() throws IOException, RegistryException {
    Image image = Image.builder(V22ManifestTemplate.class).setArchitecture("wasm").build();

    when(buildContext.getEnablePlatformTags()).thenReturn(true);

    List<PushImageStep> pushImageStepList =
        PushImageStep.makeList(
            buildContext,
            progressDispatcherFactory,
            registryClient,
            new BlobDescriptor(mockDescriptorDigest),
            image,
            false);

    ArgumentCaptor<String> tagCatcher = ArgumentCaptor.forClass(String.class);
    when(registryClient.pushManifest(any(), tagCatcher.capture())).thenReturn(null);

    assertThat(pushImageStepList).hasSize(2);
    pushImageStepList.get(0).call();
    pushImageStepList.get(1).call();

    assertThat(tagCatcher.getAllValues()).containsExactly("tag1-wasm", "tag2-wasm");
  }

  @Test
  public void testMakeList_multiPlatform_nonPlatformTags() throws IOException, RegistryException {
    Image image = Image.builder(V22ManifestTemplate.class).setArchitecture("wasm").build();