github.com/anchore/syft@v1.38.2/syft/pkg/cataloger/homebrew/package_test.go (about) 1 package homebrew 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_packageURL(t *testing.T) { 10 tests := []struct { 11 name string 12 packageName string 13 packageVersion string 14 expected string 15 }{ 16 // preemptive based on https://github.com/package-url/purl-spec/pull/281 17 { 18 name: "standard homebrew package URL", 19 packageName: "foo", 20 packageVersion: "1.2.3", 21 expected: "pkg:brew/foo@1.2.3", 22 }, 23 { 24 name: "another example", 25 packageName: "bar", 26 packageVersion: "9.8.7", 27 expected: "pkg:brew/bar@9.8.7", 28 }, 29 } 30 31 for _, test := range tests { 32 t.Run(test.name, func(t *testing.T) { 33 actual := packageURL(test.packageName, test.packageVersion) 34 assert.Equal(t, test.expected, actual, "expected package URL to match") 35 }) 36 } 37 }