removed old tests: TestMapOfObjectsSchema, TestSliceOfObjectsSchema

This commit is contained in:
Shreyas Goenka 2023-01-17 18:02:14 +01:00
parent a173d89ffa
commit ef6737d7de
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 0 additions and 106 deletions

View File

@ -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"`