Skip to content

Commit

Permalink
Load error filters from test packages
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano committed Nov 14, 2023
1 parent 77e3533 commit 36389db
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
18 changes: 8 additions & 10 deletions code/go/pkg/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package validator

import (
"errors"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -248,23 +249,20 @@ func TestValidateFile(t *testing.T) {
},
}

filter := specerrors.NewFilter(&specerrors.ConfigFilter{
Errors: specerrors.Processors{
// TODO: Actually fix the references instead of ignoring the error.
ExcludeChecks: []string{"SVR00004"},
},
})

for pkgName, test := range tests {
t.Run(pkgName, func(t *testing.T) {
pkgRootPath := filepath.Join("..", "..", "..", "..", "test", "packages", pkgName)
errPrefix := fmt.Sprintf("file \"%s/%s\" is invalid: ", pkgRootPath, test.invalidPkgFilePath)

errs := ValidateFromPath(pkgRootPath)
if verrs, ok := errs.(specerrors.ValidationErrors); ok {
result, err := filter.Run(verrs)
require.NoError(t, err)
errs = result.Processed
filterConfig, err := specerrors.LoadConfigFilter(os.DirFS(pkgRootPath))
if !errors.Is(err, os.ErrNotExist) {
filter := specerrors.NewFilter(filterConfig)
result, err := filter.Run(verrs)
require.NoError(t, err)
errs = result.Processed
}
}

if test.expectedErrContains == nil {
Expand Down
3 changes: 3 additions & 0 deletions test/packages/bad_dangling_object_ids/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
errors:
exclude_checks:
- SVR00004 # References in dashboards.
3 changes: 3 additions & 0 deletions test/packages/good_v3/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
errors:
exclude_checks:
- "PSR00001"
3 changes: 3 additions & 0 deletions test/packages/kibana_legacy_visualizations/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
errors:
exclude_checks:
- SVR00004 # References in dashboards.

0 comments on commit 36389db

Please sign in to comment.