forked from paketo-buildpacks/occam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_test.go
68 lines (57 loc) · 1.63 KB
/
image_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
package occam_test
import (
"testing"
"github.com/paketo-buildpacks/occam"
"github.com/sclevine/spec"
. "github.com/onsi/gomega"
)
func testImage(t *testing.T, context spec.G, it spec.S) {
var Expect = NewWithT(t).Expect
context("BuildpackForKey", func() {
it("returns the Buildpack with the key", func() {
image := occam.Image{
Buildpacks: []occam.ImageBuildpackMetadata{
{
Key: "first",
Layers: map[string]occam.ImageBuildpackMetadataLayer{
"first-layer-1": {
SHA: "first-layer-1-sha",
},
"first-layer-2": {
SHA: "first-layer-2-sha",
},
},
},
{
Key: "second",
Layers: map[string]occam.ImageBuildpackMetadataLayer{
"second-layer-1": {
SHA: "second-layer-1-sha",
},
"second-layer-2": {
SHA: "second-layer-2-sha",
},
},
},
},
}
firstBuildpack, err := image.BuildpackForKey("first")
Expect(err).NotTo(HaveOccurred())
Expect(firstBuildpack.Key).To(Equal("first"))
Expect(firstBuildpack.Layers["first-layer-2"].SHA).To(Equal("first-layer-2-sha"))
secondBuildpack, err := image.BuildpackForKey("second")
Expect(err).NotTo(HaveOccurred())
Expect(secondBuildpack.Key).To(Equal("second"))
Expect(secondBuildpack.Layers["second-layer-2"].SHA).To(Equal("second-layer-2-sha"))
})
context("failure cases", func() {
context("when no buildpack exists with the provided key", func() {
it("returns an error", func() {
image := occam.Image{}
_, err := image.BuildpackForKey("some-non-existent-key")
Expect(err).To(HaveOccurred())
})
})
})
})
}