-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_test.go
68 lines (54 loc) · 1.48 KB
/
build_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package entrypoint_test
import (
"errors"
"path/filepath"
"testing"
"github.com/ForestEckhardt/entrypoint/fakes"
"github.com/paketo-buildpacks/packit"
"github.com/sclevine/spec"
"github.com/ForestEckhardt/entrypoint"
. "github.com/onsi/gomega"
)
func testBuild(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect
entrypointParser *fakes.EntrypointParser
build packit.BuildFunc
)
it.Before(func() {
entrypointParser = &fakes.EntrypointParser{}
build = entrypoint.Build(entrypointParser)
})
context("there is an entrypoint.toml in the app dir", func() {
it.Before(func() {
entrypointParser.ParseCall.Returns.ProcessSlice = []packit.Process{
{
Type: "web",
Command: "some-start-command",
},
}
})
it("returns a result that sets the entrypoint", func() {
result, err := build(packit.BuildContext{
WorkingDir: "working-dir/",
})
Expect(err).NotTo(HaveOccurred())
Expect(result.Processes).To(Equal([]packit.Process{
{
Type: "web",
Command: "some-start-command",
},
}))
Expect(entrypointParser.ParseCall.Receives.Path).To(Equal(filepath.Join("working-dir/entrypoint.toml")))
})
})
context("failure cases", func() {
it.Before(func() {
entrypointParser.ParseCall.Returns.Error = errors.New("failed to parse")
})
it("returns a result that sets the entrypoint", func() {
_, err := build(packit.BuildContext{})
Expect(err).To(MatchError("failed to parse"))
})
})
}