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

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
  • Loading branch information
jjbustamante committed Jun 7, 2023
1 parent d4545c7 commit 37747ef
Showing 1 changed file with 18 additions and 1 deletion.
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 37747ef

Please sign in to comment.