github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/internal/packagemetadata/names_test.go (about) 1 package packagemetadata 2 3 import ( 4 "testing" 5 6 "github.com/google/go-cmp/cmp" 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestAllNames(t *testing.T) { 12 // note: this is a form of completion testing relative to the current code base. 13 14 expected, err := DiscoverTypeNames() 15 require.NoError(t, err) 16 17 actual := AllNames() 18 19 // ensure that the codebase (from ast analysis) reflects the latest code generated state 20 if !assert.ElementsMatch(t, expected, actual) { 21 t.Errorf("metadata types not fully represented: \n%s", cmp.Diff(expected, actual)) 22 t.Log("did you add a new pkg.*Metadata type without updating the JSON schema?") 23 t.Log("if so, you need to update the schema version and regenerate the JSON schema (make generate-json-schema)") 24 } 25 }