Skip to content

Commit 37b017f

Browse files
- Fix for windows unit test fails.
1 parent d3c5899 commit 37b017f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pkg/docval/docval_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
package docval_test
22

33
import (
4+
"os"
5+
"path/filepath"
6+
"runtime"
47
"testing"
58

69
"github.com/stackql/any-sdk/pkg/docval"
710
)
811

912
var (
10-
validator docval.FileValidator = docval.NewFileValidator("testdata/schema-definitions")
13+
validator docval.FileValidator
1114
)
1215

16+
func init() {
17+
// Normalize CWD so all relative testdata paths work
18+
_, thisFile, _, _ := runtime.Caller(0)
19+
pkgDir := filepath.Dir(thisFile)
20+
if err := os.Chdir(pkgDir); err != nil {
21+
panic(err)
22+
}
23+
24+
// Initialize validator once
25+
validator = docval.NewFileValidator(filepath.Join("testdata", "schema-definitions"))
26+
}
27+
1328
func TestValidateAndParse_ValidJSON(t *testing.T) {
1429
jsonDoc := []byte(`{"name": "Alice", "age": 30}`)
1530
jsonSchema := []byte(`{

0 commit comments

Comments
 (0)