Set offset when checking date in tests

Update integration tests that check the current date so that the offset
is set for the current time before comparing results.

See gh-34786
pull/34958/head
Phillip Webb 2 years ago
parent 712b88d3a7
commit 9b6a2a59a1

@ -322,7 +322,7 @@ class BootBuildImageIntegrationTests {
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
Image image = new DockerApi().image().inspect(ImageReference.of("docker.io/library/" + projectName));
OffsetDateTime createdDateTime = OffsetDateTime.parse(image.getCreated());
OffsetDateTime current = OffsetDateTime.now();
OffsetDateTime current = OffsetDateTime.now().withOffsetSameInstant(createdDateTime.getOffset());
assertThat(createdDateTime.getYear()).isEqualTo(current.getYear());
assertThat(createdDateTime.getMonth()).isEqualTo(current.getMonth());
assertThat(createdDateTime.getDayOfMonth()).isEqualTo(current.getDayOfMonth());

@ -427,7 +427,7 @@ class BuildImageTests extends AbstractArchiveIntegrationTests {
.inspect(ImageReference
.of("docker.io/library/build-image-current-created-date:0.0.1.BUILD-SNAPSHOT"));
OffsetDateTime createdDateTime = OffsetDateTime.parse(image.getCreated());
OffsetDateTime current = OffsetDateTime.now();
OffsetDateTime current = OffsetDateTime.now().withOffsetSameInstant(createdDateTime.getOffset());
assertThat(createdDateTime.getYear()).isEqualTo(current.getYear());
assertThat(createdDateTime.getMonth()).isEqualTo(current.getMonth());
assertThat(createdDateTime.getDayOfMonth()).isEqualTo(current.getDayOfMonth());

Loading…
Cancel
Save