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