mirror of
https://github.com/anchore/syft.git
synced 2026-04-03 05:10:36 +02:00
* refactor source API and syft json source block Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update source detection and format test utils Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * generate list of all source metadata types Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * extract base and root normalization into helper functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * preserve syftjson model package name import ref Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * alias should not be a pointer Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
30 lines
912 B
Go
30 lines
912 B
Go
package sourcemetadata
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAllNames(t *testing.T) {
|
|
// note: this is a form of completion testing relative to the current code base.
|
|
|
|
expected, err := DiscoverTypeNames()
|
|
require.NoError(t, err)
|
|
|
|
actual := AllNames()
|
|
|
|
// ensure that the codebase (from ast analysis) reflects the latest code generated state
|
|
if !assert.ElementsMatch(t, expected, actual) {
|
|
t.Errorf("metadata types not fully represented: \n%s", cmp.Diff(expected, actual))
|
|
t.Log("did you add a new source.*Metadata type without updating the JSON schema?")
|
|
t.Log("if so, you need to update the schema version and regenerate the JSON schema (make generate-json-schema)")
|
|
}
|
|
|
|
for _, ty := range AllTypes() {
|
|
assert.NotEmpty(t, JSONName(ty), "metadata type %q does not have a JSON name", ty)
|
|
}
|
|
}
|