forked from paketo-buildpacks/go-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_test.go
121 lines (98 loc) · 2.94 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 integration_test
import (
"encoding/json"
"os"
"path/filepath"
"testing"
"time"
"github.com/BurntSushi/toml"
"github.com/onsi/gomega/format"
"github.com/paketo-buildpacks/occam"
"github.com/paketo-buildpacks/occam/packagers"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
. "github.com/onsi/gomega"
)
var builder occam.Builder
var settings struct {
Buildpacks struct {
GoDist struct {
Online string
Offline string
}
GoBuild struct {
Online string
Offline string
}
Watchexec struct {
Online string
Offline string
}
}
Buildpack struct {
ID string
Name string
}
Config struct {
GoDist string `json:"go-dist"`
Watchexec string `json:"watchexec"`
}
}
func TestIntegration(t *testing.T) {
format.MaxLength = 0
Expect := NewWithT(t).Expect
pack := occam.NewPack()
file, err := os.Open("../integration.json")
Expect(err).NotTo(HaveOccurred())
Expect(json.NewDecoder(file).Decode(&settings.Config)).To(Succeed())
Expect(file.Close()).To(Succeed())
file, err = os.Open("../buildpack.toml")
Expect(err).NotTo(HaveOccurred())
_, err = toml.NewDecoder(file).Decode(&settings)
Expect(err).NotTo(HaveOccurred())
Expect(file.Close()).To(Succeed())
root, err := filepath.Abs("./..")
Expect(err).ToNot(HaveOccurred())
buildpackStore := occam.NewBuildpackStore()
libpakBuildpackStore := occam.NewBuildpackStore().WithPackager(packagers.NewLibpak())
settings.Buildpacks.GoBuild.Online, err = buildpackStore.Get.
WithVersion("1.2.3").
Execute(root)
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.GoBuild.Offline, err = buildpackStore.Get.
WithVersion("1.2.3").
WithOfflineDependencies().
Execute(root)
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.GoDist.Online, err = buildpackStore.Get.
Execute(settings.Config.GoDist)
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.GoDist.Offline, err = buildpackStore.Get.
WithOfflineDependencies().
Execute(settings.Config.GoDist)
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.Watchexec.Online, err = libpakBuildpackStore.Get.
Execute(settings.Config.Watchexec)
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.Watchexec.Offline, err = libpakBuildpackStore.Get.
WithOfflineDependencies().
Execute(settings.Config.Watchexec)
Expect(err).ToNot(HaveOccurred())
builder, err = pack.Builder.Inspect.Execute()
Expect(err).NotTo(HaveOccurred())
SetDefaultEventuallyTimeout(10 * time.Second)
suite := spec.New("Integration", spec.Report(report.Terminal{}), spec.Parallel())
suite("BuildFailure", testBuildFailure)
suite("Default", testDefault)
suite("ImportPath", testImportPath)
suite("KeepFiles", testKeepFiles)
suite("Mod", testMod)
suite("Rebuild", testRebuild)
suite("Targets", testTargets)
suite("Vendor", testVendor)
suite("WorkUse", testWorkUse)
if builder.BuilderName != "paketobuildpacks/builder-jammy-buildpackless-static" {
suite("BuildFlags", testBuildFlags)
}
suite.Run(t)
}