This commit is contained in:
Shreyas Goenka 2024-08-22 17:40:43 +02:00
parent 7c70179091
commit 39efb705de
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
2 changed files with 6 additions and 19 deletions

View File

@ -566,22 +566,3 @@ func TestDocIngestionForTopLevelPrimitive(t *testing.T) {
assert.Equal(t, expectedSchema, string(jsonSchema))
}
func TestErrorOnMapWithoutStringKey(t *testing.T) {
type Foo struct {
Bar map[int]string `json:"bar"`
}
elem := Foo{}
_, err := New(reflect.TypeOf(elem), nil)
assert.ErrorContains(t, err, "only strings map keys are valid. key type: int")
}
func TestErrorIfStructRefersToItself(t *testing.T) {
type Foo struct {
MyFoo *Foo `json:"my_foo"`
}
elem := Foo{}
_, err := New(reflect.TypeOf(elem), nil)
assert.ErrorContains(t, err, "cycle detected. traversal trace: root -> my_foo")
}

View File

@ -379,3 +379,9 @@ func TestFromTypeSelfReferential(t *testing.T) {
// t.Log("[DEBUG] actual: ", string(jsonSchema))
// t.Log("[DEBUG] expected: ", string(expectedJson))
}
func TestFromTypeError(t *testing.T) {
type mapOfInts map[int]int
_, err := FromType(reflect.TypeOf(mapOfInts{}), nil)
assert.EqualError(t, err, "found map with non-string key: int")
}