forked from paketo-buildpacks/occam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestcontainers_test.go
42 lines (35 loc) · 999 Bytes
/
testcontainers_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
package occam_test
import (
ctx "context"
"testing"
. "github.com/onsi/gomega"
"github.com/paketo-buildpacks/occam"
"github.com/sclevine/spec"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
)
func testTestContainers(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect
testContainer occam.TestContainers
container testcontainers.Container
err error
testImage = "nginx:stable-alpine"
)
it.Before(func() {
testContainer = occam.NewTestContainers()
})
it.After(func() {
err := container.Terminate(ctx.Background())
Expect(err).ToNot(HaveOccurred())
})
context("TestContainers", func() {
it("should work", func() {
container, err = testContainer.WithWaitingFor(wait.ForAll(wait.ForLog("start worker process"), wait.ForListeningPort("80/tcp"))).
WithExposedPorts("80/tcp").
WithTimeout(10).
Execute(testImage)
Expect(err).NotTo(HaveOccurred())
})
})
}