-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_test.go
48 lines (38 loc) · 975 Bytes
/
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
package static
import (
"bytes"
"os"
"path/filepath"
"testing"
"github.com/paketo-buildpacks/nginx"
"github.com/paketo-buildpacks/packit/v2"
"github.com/paketo-buildpacks/packit/v2/scribe"
"github.com/sclevine/spec"
. "github.com/onsi/gomega"
)
func testBuild(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect
workingDir string
buffer *bytes.Buffer
)
it.Before(func() {
buffer = bytes.NewBuffer(nil)
})
context("when building", func() {
it.Before(func() {
var err error
workingDir, err = os.MkdirTemp(t.TempDir(), "working-dir-*")
Expect(err).NotTo(HaveOccurred())
})
it("generates an nginx.conf", func() {
_, err := Build(scribe.NewEmitter(buffer))(packit.BuildContext{
WorkingDir: workingDir,
})
Expect(err).NotTo(HaveOccurred())
conf, err := os.ReadFile(filepath.Join(workingDir, nginx.ConfFile))
Expect(err).NotTo(HaveOccurred())
Expect(conf).NotTo(BeEmpty())
})
})
}