diff --git a/native/build_test.go b/native/build_test.go index f69671b..47472da 100644 --- a/native/build_test.go +++ b/native/build_test.go @@ -46,16 +46,18 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { it.Before(func() { var err error - build.Logger = bard.NewLogger(&out) - sbomScanner = mocks.SBOMScanner{} - sbomScanner.On("ScanLaunch", ctx.Application.Path, libcnb.SyftJSON, libcnb.CycloneDXJSON).Return(nil) - ctx.Application.Path, err = ioutil.TempDir("", "build-application") Expect(err).NotTo(HaveOccurred()) ctx.Layers.Path, err = ioutil.TempDir("", "build-layers") Expect(err).NotTo(HaveOccurred()) + sbomScanner = mocks.SBOMScanner{} + sbomScanner.On("ScanLaunch", ctx.Application.Path, libcnb.SyftJSON, libcnb.CycloneDXJSON).Return(nil) + + build.Logger = bard.NewLogger(&out) + build.SBOMScanner = &sbomScanner + Expect(os.MkdirAll(filepath.Join(ctx.Application.Path, "META-INF"), 0755)).To(Succeed()) ctx.Buildpack.Metadata = map[string]interface{}{ diff --git a/native/native_image_test.go b/native/native_image_test.go index f4a0b9b..4f8cad1 100644 --- a/native/native_image_test.go +++ b/native/native_image_test.go @@ -84,10 +84,11 @@ func testNativeImage(t *testing.T, context spec.G, it spec.S) { }).Return(nil) executor.On("Execute", mock.MatchedBy(func(e effect.Execution) bool { - return e.Command == "native-image" && len(e.Args) == 6 && e.Args[0] == "test-argument-1" + return e.Command == "native-image" && e.Args[0] == "test-argument-1" })).Run(func(args mock.Arguments) { exec := args.Get(0).(effect.Execution) - Expect(ioutil.WriteFile(filepath.Join(layer.Path, exec.Args[5]), []byte{}, 0644)).To(Succeed()) + lastArg := exec.Args[len(exec.Args)-1] + Expect(ioutil.WriteFile(filepath.Join(layer.Path, lastArg), []byte{}, 0644)).To(Succeed()) }).Return(nil) layer, err = ctx.Layers.Layer("test-layer") @@ -153,7 +154,7 @@ func testNativeImage(t *testing.T, context spec.G, it spec.S) { Expect(err).NotTo(HaveOccurred()) }) - it.Focus("contributes native image using Main-Class", func() { + it("contributes native image using Main-Class", func() { _, err := nativeImage.Contribute(layer) Expect(err).NotTo(HaveOccurred())