Skip to content

Commit

Permalink
Merge pull request #126 from paketo-buildpacks/fix-broken-tests
Browse files Browse the repository at this point in the history
Remove Focus & fix broken tests
  • Loading branch information
Daniel Mikusa committed Dec 3, 2021
2 parents b450514 + 16d0032 commit cb6c647
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions native/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{
Expand Down
7 changes: 4 additions & 3 deletions native/native_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit cb6c647

Please sign in to comment.