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

Code before:
      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();
    Mockito.when(buildContext.isEnablePlatformTags()).thenReturn(false);

    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);


Review comment (suggestion):
Let's do static importing for these:
```suggestion
    when(registryClient.pushManifest(any(), tagCatcher.capture())).thenReturn(null);
```

Code after:
    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();
    when(buildContext.getEnablePlatformTags()).thenReturn(false);

    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);