Skip to content

Commit

Permalink
validate schema
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinAbro321 committed Jun 25, 2024
1 parent 11eb685 commit cc32e96
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/pkg/packager/lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func readAndUnmarshalYaml[T interface{}](t *testing.T, yamlString string) T {
return unmarshalledYaml
}

func TestValidateSchema(t *testing.T) {
func TestZarfSchema(t *testing.T) {
t.Parallel()
getZarfSchema := func(t *testing.T) []byte {
t.Helper()
Expand Down Expand Up @@ -183,6 +183,25 @@ func TestValidateSchema(t *testing.T) {

require.ElementsMatch(t, expectedSchemaStrings, schemaStrings)
})

t.Run("test schema findings is created as expected", func(t *testing.T) {
t.Parallel()
findings, err := validateSchema(getZarfSchema(t), types.ZarfPackage{
Kind: types.ZarfInitConfig,
Metadata: types.ZarfMetadata{
Name: "invalid",
},
})
require.NoError(t, err)
expected := []types.PackageFinding{
{
Description: "Invalid type. Expected: array, given: null",
Severity: types.SevErr,
YqPath: ".components",
},
}
require.ElementsMatch(t, expected, findings)
})
}

func TestValidateComponent(t *testing.T) {
Expand Down

0 comments on commit cc32e96

Please sign in to comment.