-
Notifications
You must be signed in to change notification settings - Fork 0
/
tarantool_test.go
52 lines (46 loc) · 1.11 KB
/
tarantool_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package tarantool
import "testing"
// These are just sanity tests
func TestValidateGood(t *testing.T) {
schema := `{
"type": "record",
"name": "User",
"fields": [
{"name": "username", "type": "string"},
{"name": "phone", "type": "long"},
{"name": "age", "type": "int"}
]
}`
if err := Validate(schema); err != nil {
t.Fatalf("expected schema to pass validation: %s", err)
}
}
func TestValidateBad(t *testing.T) {
schemas := []string{
// invalid `array` type above
`{
"type": "record",
"name": "User",
"fields": [
{"name": "username", "type": "array"},
{"name": "phone", "type": "long"},
{"name": "age", "type": "int"}
]
}`,
// invalid json (notice username has only one quotes)
`{
"type": "record",
"name": "User",
"fields": [
{"name": username", "type": "string"},
{"name": "phone", "type": "long"},
{"name": "age", "type": "int"}
]
}`,
}
for _, schema := range schemas {
if err := Validate(schema); err == nil {
t.Fatalf("expected schema to fail validation but it passed")
}
}
}