Skip to content

Commit

Permalink
Fixing unit test after updating the error message
Browse files Browse the repository at this point in the history
Adding test case for warning message
Fixing error with docker library 24.0.0 see https://github.com/moby/moby/pull/45562/files

Signed-off-by: Juan Bustamante <[email protected]>
  • Loading branch information
jjbustamante committed Jun 7, 2023
1 parent d4545c7 commit d2be746
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/apex/log v1.9.0
github.com/buildpacks/imgutil v0.0.0-20230428141433-24db5a78c900
github.com/buildpacks/lifecycle v0.17.0-pre.2
github.com/docker/cli v24.0.0+incompatible
github.com/docker/docker v24.0.0+incompatible
github.com/docker/cli v24.0.1+incompatible
github.com/docker/docker v24.0.1+incompatible
github.com/docker/go-connections v0.4.0
github.com/dustin/go-humanize v1.0.1
github.com/gdamore/tcell/v2 v2.6.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi
github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE=
github.com/docker/cli v24.0.0+incompatible h1:0+1VshNwBQzQAx9lOl+OYCTCEAD8fKs/qeXMx3O0wqM=
github.com/docker/cli v24.0.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/cli v24.0.1+incompatible h1:uVl5Xv/39kZJpDo9VaktTOYBc702sdYYF33FqwUG/dM=
github.com/docker/cli v24.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v24.0.0+incompatible h1:z4bf8HvONXX9Tde5lGBMQ7yCJgNahmJumdrStZAbeY4=
github.com/docker/docker v24.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v24.0.1+incompatible h1:NxN81beIxDlUaVt46iUQrYHD9/W3u9EGl52r86O/IGw=
github.com/docker/docker v24.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
Expand Down
19 changes: 18 additions & 1 deletion internal/commands/buildpack_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ func testPackageCommand(t *testing.T, when spec.G, it spec.S) {
h.AssertError(t, err, fmt.Sprintf("invalid format %s; please use '<buildpack-id>@<buildpack-version>' to exclude buildpack from flattening", "some-buildpack"))
})
})

when("no exclusions", func() {
it("creates package with correct image name and warns flatten is being used", func() {
cmd := packageCommand(
withClientConfig(config.Config{Experimental: true}),
withBuildpackPackager(fakeBuildpackPackager),
withLogger(logger),
)
cmd.SetArgs([]string{"my-flatten-image", "-f", "file", "--flatten"})
err := cmd.Execute()
h.AssertNil(t, err)

receivedOptions := fakeBuildpackPackager.CreateCalledWithOptions
h.AssertEq(t, receivedOptions.Name, "my-flatten-image.cnb")
h.AssertContains(t, outBuf.String(), "Flattening a buildpack package could break the distribution specification. Please use it with caution.")
})
})
})

when("experimental is false", func() {
Expand All @@ -139,7 +156,7 @@ func testPackageCommand(t *testing.T, when spec.G, it spec.S) {
cmd.SetArgs([]string{"test", "-f", "file", "--flatten"})

err := cmd.Execute()
h.AssertError(t, err, "Flattening a buildpack package currently experimental.")
h.AssertError(t, err, "Flattening a buildpack package is currently experimental.")
})
})
})
Expand Down

0 comments on commit d2be746

Please sign in to comment.