github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/pkg/cataloger/golang/package_test.go (about) 1 package golang 2 3 import ( 4 "testing" 5 6 "github.com/nextlinux/gosbom/gosbom/pkg" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func Test_packageURL(t *testing.T) { 11 12 tests := []struct { 13 name string 14 pkg pkg.Package 15 expected string 16 }{ 17 { 18 name: "gocase", 19 pkg: pkg.Package{ 20 Name: "github.com/nextlinux/gosbom", 21 Version: "v0.1.0", 22 }, 23 expected: "pkg:golang/github.com/nextlinux/gosbom@v0.1.0", 24 }, 25 { 26 name: "golang short name", 27 pkg: pkg.Package{ 28 Name: "go.opencensus.io", 29 Version: "v0.23.0", 30 }, 31 expected: "pkg:golang/go.opencensus.io@v0.23.0", 32 }, 33 } 34 35 for _, test := range tests { 36 t.Run(test.name, func(t *testing.T) { 37 assert.Equal(t, test.expected, packageURL(test.pkg.Name, test.pkg.Version)) 38 }) 39 } 40 }