added test for map of map

This commit is contained in:
Shreyas Goenka 2023-01-17 17:57:48 +01:00
parent 753c54e899
commit bd6d0dca57
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 25 additions and 1 deletions

View File

@ -21,7 +21,6 @@ import (
// TODO: Have a test that combines multiple different cases
// TODO: have a test for what happens when omitempty in different cases: primitives, object, map, array
func TestIntSchema(t *testing.T) {
var elemInt int
@ -354,6 +353,31 @@ func TestMapOfStructSchema(t *testing.T) {
assert.Equal(t, expected, string(jsonSchema))
}
func TestMapOfMapSchema(t *testing.T) {
var elem map[string]map[string]int
schema, err := NewSchema(reflect.TypeOf(elem))
assert.NoError(t, err)
jsonSchema, err := json.MarshalIndent(schema, " ", " ")
assert.NoError(t, err)
expected :=
`{
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "number"
}
}
}`
t.Log("[DEBUG] actual: ", string(jsonSchema))
t.Log("[DEBUG] expected: ", expected)
assert.Equal(t, expected, string(jsonSchema))
}
func TestObjectSchema(t *testing.T) {
type Person struct {
Name string `json:"name"`