github.com/buildpacks/pack@v0.33.3-0.20240516162812-884dd1837311/pkg/dist/extension_descriptor_test.go (about) 1 package dist_test 2 3 import ( 4 "testing" 5 6 "github.com/buildpacks/lifecycle/api" 7 "github.com/heroku/color" 8 "github.com/sclevine/spec" 9 "github.com/sclevine/spec/report" 10 11 "github.com/buildpacks/pack/pkg/buildpack" 12 "github.com/buildpacks/pack/pkg/dist" 13 h "github.com/buildpacks/pack/testhelpers" 14 ) 15 16 func TestExtensionDescriptor(t *testing.T) { 17 color.Disable(true) 18 defer color.Disable(false) 19 spec.Run(t, "testExtensionDescriptor", testExtensionDescriptor, spec.Parallel(), spec.Report(report.Terminal{})) 20 } 21 22 func testExtensionDescriptor(t *testing.T, when spec.G, it spec.S) { 23 when("#EscapedID", func() { 24 it("returns escaped ID", func() { 25 extDesc := dist.ExtensionDescriptor{ 26 WithInfo: dist.ModuleInfo{ID: "some/id"}, 27 } 28 h.AssertEq(t, extDesc.EscapedID(), "some_id") 29 }) 30 }) 31 32 when("#Kind", func() { 33 it("returns 'extension'", func() { 34 extDesc := dist.ExtensionDescriptor{} 35 h.AssertEq(t, extDesc.Kind(), buildpack.KindExtension) 36 }) 37 }) 38 39 when("#API", func() { 40 it("returns the api", func() { 41 extDesc := dist.ExtensionDescriptor{ 42 WithAPI: api.MustParse("0.99"), 43 } 44 h.AssertEq(t, extDesc.API().String(), "0.99") 45 }) 46 }) 47 48 when("#Info", func() { 49 it("returns the module info", func() { 50 info := dist.ModuleInfo{ 51 ID: "some-id", 52 Name: "some-name", 53 Version: "some-version", 54 } 55 extDesc := dist.ExtensionDescriptor{ 56 WithInfo: info, 57 } 58 h.AssertEq(t, extDesc.Info(), info) 59 }) 60 }) 61 62 when("#Order", func() { 63 it("returns empty", func() { 64 var empty dist.Order 65 extDesc := dist.ExtensionDescriptor{} 66 h.AssertEq(t, extDesc.Order(), empty) 67 }) 68 }) 69 70 when("#Stacks", func() { 71 it("returns empty", func() { 72 var empty []dist.Stack 73 extDesc := dist.ExtensionDescriptor{} 74 h.AssertEq(t, extDesc.Stacks(), empty) 75 }) 76 }) 77 }