Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspect image: add one unit test #1744

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/client/inspect_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (c *Client) InspectImage(name string, daemon bool) (*ImageInfo, error) {
}

var stackCompat platform.StackMetadata
if layersMd.RunImage.Image != "" { // TODO: add unit
if layersMd.RunImage.Image != "" {
stackCompat = layersMd.RunImage.ToStackMetadata()
} else {
stackCompat = layersMd.Stack
Expand Down
17 changes: 17 additions & 0 deletions pkg/client/inspect_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,23 @@ func testInspectImage(t *testing.T, when spec.G, it spec.S) {
h.AssertEq(t, infoWithExtension.StackID, "test.stack.id")
})

it("returns the stack from runImage.Image if set", func() {
h.AssertNil(t, mockImage.SetLabel(
"io.buildpacks.lifecycle.metadata",
`{
"runImage": {
"topLayer": "some-top-layer",
"reference": "some-run-image-reference",
"image": "is everything"
}
}`,
))
info, err := subject.InspectImage("some/image", useDaemon)
h.AssertNil(t, err)
h.AssertEq(t, info.Stack,
platform.StackMetadata{RunImage: platform.RunImageForExport{Image: "is everything"}})
})

it("returns the stack", func() {
info, err := subject.InspectImage("some/image", useDaemon)
h.AssertNil(t, err)
Expand Down