forked from buildpacks/pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildpack_test.go
61 lines (47 loc) · 1.44 KB
/
buildpack_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
package registry_test
import (
"testing"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/buildpacks/pack/internal/registry"
h "github.com/buildpacks/pack/testhelpers"
)
func TestRegistryBuildpack(t *testing.T) {
spec.Run(t, "Buildpack", testRegistryBuildpack, spec.Parallel(), spec.Report(report.Terminal{}))
}
func testRegistryBuildpack(t *testing.T, when spec.G, it spec.S) {
when("#Validate", func() {
it("errors when address is missing", func() {
b := registry.Buildpack{
Address: "",
}
h.AssertNotNil(t, registry.Validate(b))
})
it("errors when not a digest", func() {
b := registry.Buildpack{
Address: "example.com/some/package:18",
}
h.AssertNotNil(t, registry.Validate(b))
})
it("succeeds when address is a digest", func() {
b := registry.Buildpack{
Address: "example.com/some/package@sha256:8c27fe111c11b722081701dfed3bd55e039b9ce92865473cf4cdfa918071c566",
}
h.AssertNil(t, registry.Validate(b))
})
})
when("#ParseNamespaceName", func() {
it("should parse buildpack id into namespace and name", func() {
const id = "heroku/rust@1.2.3"
namespace, name, err := registry.ParseNamespaceName(id)
h.AssertNil(t, err)
h.AssertEq(t, namespace, "heroku")
h.AssertEq(t, name, "rust@1.2.3")
})
it("should provide an error for invalid id", func() {
const id = "bad id"
_, _, err := registry.ParseNamespaceName(id)
h.AssertNotNil(t, err)
})
})
}