Skip to content

Commit

Permalink
added test for nullable schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
ghik committed Apr 22, 2024
1 parent d0a8fa9 commit 8807c3f
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class SchemaComparatorTest extends AnyFunSuite {
assert(compare(ref("Something"), ref("Something")) == List(
TypeMismatch(List(SchemaType.String), List(SchemaType.Integer))
))
assert(compare(ref("Integer"), ref("Something")) == Nil)
assert(compare(ref("Something"), ref("String")) == Nil)
}

test("recursive schemas") {
Expand All @@ -130,6 +132,23 @@ class SchemaComparatorTest extends AnyFunSuite {
))
}

test("nullable schemas") {
assert(compare(stringSchema, stringSchema.nullable) == Nil)
assert(compare(opaqueSchema, opaqueSchema.nullable) == Nil)
assert(compare(ref("String"), ref("String").nullable) == Nil)
assert(compare(integerSchema.nullable, numberSchema.nullable) == Nil)

assert(compare(stringSchema.nullable, stringSchema) == List(
TypeMismatch(List(SchemaType.Null), List(SchemaType.String))
))
assert(compare(opaqueSchema.nullable, opaqueSchema) == List(
GeneralSchemaMismatch(opaqueSchema.nullable, opaqueSchema) //TODO better issue?
))
assert(compare(ref("String").nullable, ref("String")) == List(
GeneralSchemaMismatch(ref("String").nullable, stringSchema) //TODO better issue?
))
}

test("enum and const mismatch") {
def enums(values: Any*): List[ExampleSingleValue] =
values.toList.map(ExampleSingleValue)
Expand Down

0 comments on commit 8807c3f

Please sign in to comment.