Files
edge/pkg/storage/filter/filter_test.go
William Petit 4d064de164
All checks were successful
arcad/edge/pipeline/head This commit looks good
feat(filter): add basic json parsing test case
2023-10-11 11:43:17 +02:00

38 lines
705 B
Go

package filter
import (
"encoding/json"
"os"
"path/filepath"
"testing"
"github.com/pkg/errors"
)
func TestFilterFromJSON(t *testing.T) {
files, err := filepath.Glob("testdata/json/*.json")
if err != nil {
t.Fatalf("%+v", errors.WithStack(err))
}
for _, f := range files {
testName := filepath.Base(f)
t.Run(testName, func(t *testing.T) {
data, err := os.ReadFile(f)
if err != nil {
t.Fatalf("%+v", errors.WithStack(err))
}
var rawFilter map[string]any
if err := json.Unmarshal(data, &rawFilter); err != nil {
t.Fatalf("%+v", errors.WithStack(err))
}
if _, err := NewFrom(rawFilter); err != nil {
t.Fatalf("%+v", errors.WithStack(err))
}
})
}
}