-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit_test.go
59 lines (45 loc) · 1.35 KB
/
init_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
package acceptance_test
import (
"fmt"
"net"
"path/filepath"
"testing"
"time"
"github.com/google/uuid"
"github.com/onsi/gomega/format"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
. "github.com/onsi/gomega"
)
var stack struct {
BuildArchive string
RunArchive string
BuildImageID string
RunImageID string
}
var localRegistryPort int
func by(_ string, f func()) { f() }
func getFreePort() (port int, err error) {
if l, err := net.Listen("tcp", ":0"); err == nil {
defer l.Close()
return l.Addr().(*net.TCPAddr).Port, nil
}
return 0, err
}
func TestAcceptance(t *testing.T) {
format.MaxLength = 0
SetDefaultEventuallyTimeout(30 * time.Second)
Expect := NewWithT(t).Expect
root, err := filepath.Abs(".")
Expect(err).ToNot(HaveOccurred())
localRegistryPort, err = getFreePort()
Expect(err).ToNot(HaveOccurred())
stack.BuildArchive = filepath.Join(root, "build", "build.oci")
stack.BuildImageID = fmt.Sprintf("localhost:%d/stack-build-%s", localRegistryPort, uuid.NewString())
stack.RunArchive = filepath.Join(root, "build", "run.oci")
stack.RunImageID = fmt.Sprintf("localhost:%d/stack-run-%s", localRegistryPort, uuid.NewString())
suite := spec.New("Acceptance", spec.Report(report.Terminal{}), spec.Parallel())
suite("Metadata", testMetadata)
suite("BuildpackIntegration", testBuildpackIntegration)
suite.Run(t)
}