MCPcopy Create free account
hub / github.com/github/gh-aw / TestCompileSchema

Function TestCompileSchema

pkg/parser/schema_compiler_test.go:7–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5import "testing"
6
7func TestCompileSchema(t *testing.T) {
8 t.Parallel()
9
10 schema, err := CompileSchema(`{
11 "type": "object",
12 "properties": {
13 "name": {"type": "string"}
14 },
15 "required": ["name"],
16 "additionalProperties": false
17 }`, "http://example.com/schema.json")
18 if err != nil {
19 t.Fatalf("CompileSchema returned error: %v", err)
20 }
21
22 if err := schema.Validate(map[string]any{"name": "gh-aw"}); err != nil {
23 t.Fatalf("Validate(valid) returned error: %v", err)
24 }
25
26 if err := schema.Validate(map[string]any{"name": 1}); err == nil {
27 t.Fatal("Validate(invalid) returned nil error, want validation failure")
28 }
29}

Callers

nothing calls this directly

Calls 2

CompileSchemaFunction · 0.85
ValidateMethod · 0.45

Tested by

no test coverage detected