mirror of https://github.com/databricks/cli.git
added test for map of map
This commit is contained in:
parent
753c54e899
commit
bd6d0dca57
|
@ -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"`
|
||||
|
|
Loading…
Reference in New Issue