Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
fix(java-buildpack): Treat empty BP_FUNCTION the same as unset
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Meyer <[email protected]>
  • Loading branch information
menehune23 authored and andrew-su committed Oct 20, 2022
1 parent f37ccf9 commit 9ab1b25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion buildpacks/java/java/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Detect struct {
}

func (d Detect) checkConfigs(cr libpak.ConfigurationResolver) bool {
if _, defined := cr.Resolve("BP_FUNCTION"); defined {
if val, defined := cr.Resolve("BP_FUNCTION"); defined && val != "" {
return true
}

Expand Down
16 changes: 15 additions & 1 deletion buildpacks/java/tests/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,21 @@ func testDetect(t *testing.T, when spec.G, it spec.S) {

when("BP_FUNCTION is not configured", func() {
it.Before(func() {
Expect(os.Unsetenv("BP_FUNCTION")).To(Succeed())
t.Setenv("BP_FUNCTION", "")
Expect(os.Unsetenv("BP_FUNCTION")).To(Succeed()) // needed in combination with above, so original value will be restored
})

it("fails detection", func() {
result, err := detect.Detect(context)
Expect(err).NotTo(HaveOccurred())

Expect(result.Pass).To(BeFalse())
})
})

when("BP_FUNCTION is empty", func() {
it.Before(func() {
t.Setenv("BP_FUNCTION", "")
})

it("fails detection", func() {
Expand Down

0 comments on commit 9ab1b25

Please sign in to comment.