(t *testing.T)
| 5 | import "testing" |
| 6 | |
| 7 | func 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 | } |
nothing calls this directly
no test coverage detected