Browse Source

Add more tests for Image.getOs()

See gh-45305

Signed-off-by: Johnny Lim <izeye@naver.com>
pull/45382/head
Johnny Lim 8 months ago committed by Moritz Halbritter
parent
commit
9a0f7a4013
  1. 12
      spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/type/ImageTests.java
  2. 30
      spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/docker/type/image-empty-os.json
  3. 30
      spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/docker/type/image-non-default-os.json

12
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/type/ImageTests.java

@ -67,6 +67,18 @@ class ImageTests extends AbstractJsonTests { @@ -67,6 +67,18 @@ class ImageTests extends AbstractJsonTests {
assertThat(image.getOs()).isEqualTo("linux");
}
@Test
void getOsWhenOsIsNotDefaultOsReturnsOs() throws Exception {
Image image = Image.of(getContent("image-non-default-os.json"));
assertThat(image.getOs()).isEqualTo("windows");
}
@Test
void getOsWhenOsIsEmptyReturnsDefaultOs() throws Exception {
Image image = Image.of(getContent("image-empty-os.json"));
assertThat(image.getOs()).isEqualTo("linux");
}
@Test
void getCreatedReturnsDate() throws Exception {
Image image = getImage();

30
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/docker/type/image-empty-os.json

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
{
"Id": "sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba",
"RepoTags": [
"ghcr.io/spring-io/spring-boot-cnb-test-builder:0.0.1"
],
"RepoDigests": [
"ghcr.io/spring-io/spring-boot-cnb-test-builder@sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba"
],
"Parent": "",
"Comment": "",
"DockerVersion": "",
"Author": "",
"Config": null,
"Architecture": "",
"Os": "",
"Size": 166797518,
"GraphDriver": {
"Data": null,
"Name": "overlayfs"
},
"RootFS": {},
"Metadata": {
"LastTagTime": "2025-04-10T22:41:27.520294922Z"
},
"Descriptor": {
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba",
"size": 513
}
}

30
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/docker/type/image-non-default-os.json

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
{
"Id": "sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba",
"RepoTags": [
"ghcr.io/spring-io/spring-boot-cnb-test-builder:0.0.1"
],
"RepoDigests": [
"ghcr.io/spring-io/spring-boot-cnb-test-builder@sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba"
],
"Parent": "",
"Comment": "",
"DockerVersion": "",
"Author": "",
"Config": null,
"Architecture": "",
"Os": "windows",
"Size": 166797518,
"GraphDriver": {
"Data": null,
"Name": "overlayfs"
},
"RootFS": {},
"Metadata": {
"LastTagTime": "2025-04-10T22:41:27.520294922Z"
},
"Descriptor": {
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba",
"size": 513
}
}
Loading…
Cancel
Save