mirror of https://github.com/databricks/cli.git
removed old tests: TestMapOfObjectsSchema, TestSliceOfObjectsSchema
This commit is contained in:
parent
a173d89ffa
commit
ef6737d7de
|
@ -472,112 +472,6 @@ func TestObjectSchema(t *testing.T) {
|
|||
assert.Equal(t, expected, string(jsonSchema))
|
||||
}
|
||||
|
||||
func TestSliceOfObjectsSchema(t *testing.T) {
|
||||
type Person struct {
|
||||
Name string `json:"name"`
|
||||
Age int `json:"age,omitempty"`
|
||||
}
|
||||
|
||||
type Plot struct {
|
||||
MainCharacters []Person `json:"main_characters"`
|
||||
}
|
||||
|
||||
type Story struct {
|
||||
Plot Plot `json:"plot"`
|
||||
}
|
||||
|
||||
elem := Story{}
|
||||
|
||||
schema, err := NewSchema(reflect.TypeOf(elem))
|
||||
assert.NoError(t, err)
|
||||
|
||||
jsonSchema, err := json.MarshalIndent(schema, " ", " ")
|
||||
assert.NoError(t, err)
|
||||
|
||||
expected :=
|
||||
`{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"plot": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"main_characters": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"age": {
|
||||
"type": "number"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
t.Log("[DEBUG] actual: ", string(jsonSchema))
|
||||
t.Log("[DEBUG] expected: ", expected)
|
||||
assert.Equal(t, expected, string(jsonSchema))
|
||||
}
|
||||
|
||||
func TestMapOfObjectsSchema(t *testing.T) {
|
||||
type Person struct {
|
||||
Name string `json:"name"`
|
||||
Age int `json:"age,omitempty"`
|
||||
}
|
||||
|
||||
type Plot struct {
|
||||
Events map[string]Person `json:"events"`
|
||||
}
|
||||
|
||||
type Story struct {
|
||||
Plot Plot `json:"plot"`
|
||||
}
|
||||
|
||||
elem := Story{}
|
||||
|
||||
schema, err := NewSchema(reflect.TypeOf(elem))
|
||||
assert.NoError(t, err)
|
||||
|
||||
jsonSchema, err := json.MarshalIndent(schema, " ", " ")
|
||||
assert.NoError(t, err)
|
||||
|
||||
expected :=
|
||||
`{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"plot": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"events": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"age": {
|
||||
"type": "number"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
t.Log("[DEBUG] actual: ", string(jsonSchema))
|
||||
t.Log("[DEBUG] expected: ", expected)
|
||||
assert.Equal(t, expected, string(jsonSchema))
|
||||
}
|
||||
|
||||
func TestEmbeddedStructSchema(t *testing.T) {
|
||||
type Person struct {
|
||||
Name string `json:"name"`
|
||||
|
|
Loading…
Reference in New Issue