github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/javascript/key/key_test.go (about) 1 package key 2 3 import "testing" 4 5 func TestNpmPackageKey(t *testing.T) { 6 tests := []struct { 7 name string 8 version string 9 expected string 10 }{ 11 {"lodash", "1.0.0", "lodash:1.0.0"}, 12 {"react", "16.8.0", "react:16.8.0"}, 13 {"", "1.0.0", ":1.0.0"}, 14 {"lodash", "", "lodash:"}, 15 {"", "", ":"}, 16 } 17 18 for _, tt := range tests { 19 t.Run(tt.name+":"+tt.version, func(t *testing.T) { 20 got := NpmPackageKey(tt.name, tt.version) 21 if got != tt.expected { 22 t.Errorf("NpmPackageKey(%q, %q) = %q; want %q", tt.name, tt.version, got, tt.expected) 23 } 24 }) 25 } 26 }