Skip to content

Commit 24c9dd6

Browse files
committed
Merge pull request #45305 from izeye
* pr/45305: Add more tests for Image.getOs() Closes gh-45305
2 parents ee0beed + 9a0f7a4 commit 24c9dd6

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

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

+12
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ void getOsReturnsOs() throws Exception {
6767
assertThat(image.getOs()).isEqualTo("linux");
6868
}
6969

70+
@Test
71+
void getOsWhenOsIsNotDefaultOsReturnsOs() throws Exception {
72+
Image image = Image.of(getContent("image-non-default-os.json"));
73+
assertThat(image.getOs()).isEqualTo("windows");
74+
}
75+
76+
@Test
77+
void getOsWhenOsIsEmptyReturnsDefaultOs() throws Exception {
78+
Image image = Image.of(getContent("image-empty-os.json"));
79+
assertThat(image.getOs()).isEqualTo("linux");
80+
}
81+
7082
@Test
7183
void getCreatedReturnsDate() throws Exception {
7284
Image image = getImage();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"Id": "sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba",
3+
"RepoTags": [
4+
"ghcr.io/spring-io/spring-boot-cnb-test-builder:0.0.1"
5+
],
6+
"RepoDigests": [
7+
"ghcr.io/spring-io/spring-boot-cnb-test-builder@sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba"
8+
],
9+
"Parent": "",
10+
"Comment": "",
11+
"DockerVersion": "",
12+
"Author": "",
13+
"Config": null,
14+
"Architecture": "",
15+
"Os": "",
16+
"Size": 166797518,
17+
"GraphDriver": {
18+
"Data": null,
19+
"Name": "overlayfs"
20+
},
21+
"RootFS": {},
22+
"Metadata": {
23+
"LastTagTime": "2025-04-10T22:41:27.520294922Z"
24+
},
25+
"Descriptor": {
26+
"mediaType": "application/vnd.oci.image.index.v1+json",
27+
"digest": "sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba",
28+
"size": 513
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"Id": "sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba",
3+
"RepoTags": [
4+
"ghcr.io/spring-io/spring-boot-cnb-test-builder:0.0.1"
5+
],
6+
"RepoDigests": [
7+
"ghcr.io/spring-io/spring-boot-cnb-test-builder@sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba"
8+
],
9+
"Parent": "",
10+
"Comment": "",
11+
"DockerVersion": "",
12+
"Author": "",
13+
"Config": null,
14+
"Architecture": "",
15+
"Os": "windows",
16+
"Size": 166797518,
17+
"GraphDriver": {
18+
"Data": null,
19+
"Name": "overlayfs"
20+
},
21+
"RootFS": {},
22+
"Metadata": {
23+
"LastTagTime": "2025-04-10T22:41:27.520294922Z"
24+
},
25+
"Descriptor": {
26+
"mediaType": "application/vnd.oci.image.index.v1+json",
27+
"digest": "sha256:21635a6b4880772f3fabbf8b660907fa38636558cf787cc26f1779fc4b4e2cba",
28+
"size": 513
29+
}
30+
}

0 commit comments

Comments
 (0)