forked from paketo-community/ubi-base-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_test.go
121 lines (92 loc) · 3.07 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package acceptance_test
import (
"encoding/json"
"os"
"path/filepath"
"testing"
"time"
"github.com/paketo-buildpacks/occam"
structs "github.com/paketo-community/ubi-base-stack/internal/structs"
utils "github.com/paketo-community/ubi-base-stack/internal/utils"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
. "github.com/onsi/gomega"
)
var root string
var RegistryUrl string
var builder struct {
imageUrl string
buildImageID string
buildImageUrl string
runImageID string
runImageUrl string
}
var settings struct {
Buildpacks struct {
Nodejs struct {
Online string
}
BuildPlan struct {
Online string
}
GoDist struct {
Online string
}
}
Extensions struct {
UbiNodejsExtension struct {
Online string
}
}
Config struct {
BuildPlan string `json:"build-plan"`
UbiNodejsExtension string `json:"ubi-nodejs-extension"`
Nodejs string `json:"nodejs"`
GoDist string `json:"go-dist"`
NodeMajorVersions []int `json:"nodejs-major-versions"`
}
Stacks []structs.Stack
}
func by(_ string, f func()) { f() }
func TestAcceptance(t *testing.T) {
for _, nodeMajorVersion := range settings.Config.NodeMajorVersions {
settings.Stacks = append(settings.Stacks, structs.NewStack(nodeMajorVersion, "nodejs", root))
}
var err error
Expect := NewWithT(t).Expect
docker := occam.NewDocker()
RegistryUrl = os.Getenv("REGISTRY_URL")
Expect(RegistryUrl).NotTo(Equal(""))
root, err = filepath.Abs(".")
Expect(err).ToNot(HaveOccurred())
file, err := os.Open("./integration.json")
Expect(err).NotTo(HaveOccurred())
Expect(json.NewDecoder(file).Decode(&settings.Config)).To(Succeed())
Expect(file.Close()).To(Succeed())
buildpackStore := occam.NewBuildpackStore()
settings.Extensions.UbiNodejsExtension.Online, err = buildpackStore.Get.
Execute(settings.Config.UbiNodejsExtension)
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.Nodejs.Online, err = buildpackStore.Get.
Execute(settings.Config.Nodejs)
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.BuildPlan.Online, err = buildpackStore.Get.
Execute(settings.Config.BuildPlan)
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.GoDist.Online, err = buildpackStore.Get.
Execute(settings.Config.GoDist)
Expect(err).NotTo(HaveOccurred())
builder.buildImageID, builder.buildImageUrl, builder.runImageID, builder.runImageUrl, builder.imageUrl, err = utils.GenerateBuilder(root, "build", RegistryUrl)
Expect(err).NotTo(HaveOccurred())
SetDefaultEventuallyTimeout(120 * time.Second)
suite := spec.New("Acceptance", spec.Report(report.Terminal{}), spec.Parallel())
suite("Metadata", testMetadata)
suite("NodejsStackIntegration", testNodejsStackIntegration)
suite("buildpackIntegration", testBuildpackIntegration)
suite.Run(t)
/** Cleanup **/
lifecycleImageID, err := utils.GetLifecycleImageID(docker, builder.imageUrl)
Expect(err).NotTo(HaveOccurred())
err = utils.RemoveImages(docker, []string{builder.buildImageID, builder.runImageID, lifecycleImageID, builder.runImageUrl, builder.imageUrl})
Expect(err).NotTo(HaveOccurred())
}