MCPcopy Create free account
hub / github.com/buildpacks/pack / testInputImageReference

Function testInputImageReference

pkg/client/input_image_reference_test.go:22–91  ·  view source on GitHub ↗
(t *testing.T, when spec.G, it spec.S)

Source from the content-addressed store, hash-verified

20}
21
22func testInputImageReference(t *testing.T, when spec.G, it spec.S) {
23 var defaultImageReference, layoutImageReference InputImageReference
24
25 it.Before(func() {
26 defaultImageReference = ParseInputImageReference("busybox")
27 layoutImageReference = ParseInputImageReference("oci:my-app")
28 })
29
30 when("#ParseInputImageReference", func() {
31 when("oci layout image reference is not provided", func() {
32 it("default implementation is returned", func() {
33 h.AssertEq(t, defaultImageReference.Layout(), false)
34 h.AssertEq(t, defaultImageReference.Name(), "busybox")
35
36 fullName, err := defaultImageReference.FullName()
37 h.AssertNil(t, err)
38 h.AssertEq(t, fullName, "busybox")
39 })
40 })
41
42 when("oci layout image reference is provided", func() {
43 it("layout implementation is returned", func() {
44 h.AssertTrue(t, layoutImageReference.Layout())
45 h.AssertEq(t, layoutImageReference.Name(), "my-app")
46 })
47 })
48 })
49
50 when("#FullName", func() {
51 when("oci layout image reference is provided", func() {
52 when("not absolute path provided", func() {
53 it("it will be joined with the current working directory", func() {
54 fullPath, err := layoutImageReference.FullName()
55 h.AssertNil(t, err)
56
57 currentWorkingDir, err := os.Getwd()
58 h.AssertNil(t, err)
59
60 expectedPath := filepath.Join(currentWorkingDir, layoutImageReference.Name())
61 h.AssertEq(t, fullPath, expectedPath)
62 })
63 })
64
65 when("absolute path provided", func() {
66 var (
67 fullPath, expectedFullPath, tmpDir string
68 err error
69 )
70
71 it.Before(func() {
72 tmpDir, err = os.MkdirTemp("", "pack.input.image.reference.test")
73 h.AssertNil(t, err)
74 expectedFullPath = filepath.Join(tmpDir, "my-app")
75 layoutImageReference = ParseInputImageReference(fmt.Sprintf("oci:%s", expectedFullPath))
76 })
77
78 it.After(func() {
79 err = os.RemoveAll(tmpDir)

Callers

nothing calls this directly

Calls 5

LayoutMethod · 0.95
NameMethod · 0.95
FullNameMethod · 0.95
ParseInputImageReferenceFunction · 0.85
RemoveAllMethod · 0.45

Tested by

no test coverage detected