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(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());
      Assert.assertEquals("mockDescriptorDigest", buildResult.getImageId().toString());
    }
    Set<String> allValues = ImmutableSet.copyOf(tagCAtcher.getAllValues());
    Set<String> expectedTags =
        ImmutableSet.of("sha256:0dd75658cf52608fbd72eb95ff5fc5946966258c3676b35d336bfcc7ac5006f1");
    Assert.assertEquals(expectedTags, allValues);
  }

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

    ImmutableList<PushImageStep> pushImageStepList =
        PushImageStep.makeListForManifestList(
            buildContext, progressDispatcherFactory, registryClient, manifestList, false);
    Assert.assertEquals(0, pushImageStepList.size());
  }

  @Test
  public void testMakeListForManifestList_manifestListAlreadyExists() throws IOException {
    System.setProperty(JibSystemProperties.SKIP_EXISTING_IMAGES, "true");

    ImmutableList<PushImageStep> pushImageStepList =
        PushImageStep.makeListForManifestList(
            buildContext, progressDispatcherFactory, registryClient, manifestList, true);
    Assert.assertEquals(0, pushImageStepList.size());
  }
}


Review comment (suggestion):
```suggestion
assertThat(tagCatcher.getAllValues()).containsExactly("sha256:0dd75658cf52608fbd72eb95ff5fc5946966258c3676b35d336bfcc7ac5006f1");
```


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

    List<PushImageStep> pushImageStepList =
        PushImageStep.makeListForManifestList(
            buildContext, progressDispatcherFactory, registryClient, manifestList, false);
    assertThat(pushImageStepList).isEmpty();
  }

  @Test
  public void testMakeListForManifestList_manifestListAlreadyExists() throws IOException {
    System.setProperty(JibSystemProperties.SKIP_EXISTING_IMAGES, "true");

    List<PushImageStep> pushImageStepList =
        PushImageStep.makeListForManifestList(
            buildContext, progressDispatcherFactory, registryClient, manifestList, true);
    assertThat(pushImageStepList).isEmpty();
  }
}