diff --git a/buildpacks/java/java/detect.go b/buildpacks/java/java/detect.go index 0aceb5e2..68936410 100644 --- a/buildpacks/java/java/detect.go +++ b/buildpacks/java/java/detect.go @@ -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 } diff --git a/buildpacks/java/tests/detect_test.go b/buildpacks/java/tests/detect_test.go index 28665586..41f8abd4 100644 --- a/buildpacks/java/tests/detect_test.go +++ b/buildpacks/java/tests/detect_test.go @@ -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() {