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

Code before:

    Mockito.when(containerConfig.isPlatformTag()).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());
    for (PushImageStep pushImageStep : pushImageStepList) {
      BuildResult buildResult = pushImageStep.call();
      Assert.assertEquals(
          "sha256:0dd75658cf52608fbd72eb95ff5fc5946966258c3676b35d336bfcc7ac5006f1",
          buildResult.getImageDigest().toString());
      Assert.assertEquals("mockDescriptorDigest", buildResult.getImageId().toString());
    }
    Set<String> allValues = ImmutableSet.copyOf(tagCAtcher.getAllValues());
    Set<String> expectedTags = ImmutableSet.of("tag1-wasm", "tag2-wasm");
    Assert.assertEquals(expectedTags, allValues);
  }

  @Test
  public void testMakeList_multiPlatform_disabled() throws IOException, RegistryException {
    Image asd = Image.builder(V22ManifestTemplate.class).setArchitecture("wasm").build();
    Mockito.when(containerConfig.isPlatformTag()).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);

    Assert.assertEquals(1, pushImageStepList.size());
    for (PushImageStep pushImageStep : pushImageStepList) {
      BuildResult buildResult = pushImageStep.call();
      Assert.assertEquals(
          "sha256:0dd75658cf52608fbd72eb95ff5fc5946966258c3676b35d336bfcc7ac5006f1",
          buildResult.getImageDigest().toString());

Review comment (suggestion):
```suggestion
    assertThat(tagCatcher.getAllValues()).containsExactly("tag1-wasm", "tag2-wasm")
```
We also need to add `import static com.google.common.truth.Truth.assertThat;` to the import statements.

Code after:
    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);

    assertThat(pushImageStepList).hasSize(1);
    pushImageStepList.get(0).call();
    assertThat(tagCatcher.getAllValues())
        .containsExactly("sha256:0dd75658cf52608fbd72eb95ff5fc5946966258c3676b35d336bfcc7ac5006f1");
  }

  @Test
  public void testMakeListForManifestList_singlePlatform() throws IOException {
    when(containerConfig.getPlatforms())
        .thenReturn(ImmutableSet.of(new Platform("amd64", "linux")));