Skip to content

Commit

Permalink
feat: Correct the matching rules to match the latest compatibility-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Jun 29, 2023
1 parent 7f9d5ae commit 68b8822
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private val booleanRegex = Regex("^true|false$")
fun valueOf(value: Any?): String {
return when (value) {
null -> "null"
is String -> "'$value'"
is String, is JsonValue.StringValue -> "'$value'"
is Element -> "<${QualifiedName(value)}>"
is Text -> "'${value.wholeText}'"
is JsonValue -> value.serialise()
Expand Down Expand Up @@ -222,7 +222,7 @@ fun <M : Mismatch> matchType(
allowEmpty: Boolean
): List<M> {
logger.debug {
"comparing type of ${valueOf(actual)} (${typeOf(actual)}) to ${valueOf(expected)} (${typeOf(expected)}) at $path"
"comparing type of [$actual] (${actual?.javaClass?.simpleName}) to [$expected] (${expected?.javaClass?.simpleName}) at $path"
}
return if (expected is Number && actual is Number ||
expected is Boolean && actual is Boolean ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class EachValueMatcherSpec extends Specification {

then:
result.mismatches*.mismatch == [
'Expected 100 (Integer) to be the same type as "foo" (String)',
"Expected \"x\" to match '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\\*'"
"Expected 100 (Integer) to be the same type as 'foo' (String)",
"Expected 'x' to match '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\\*'"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ class JsonContentMatcherSpec extends Specification {
then:
!mismatches.empty
mismatches*.mismatch == ['Expected [red, blue] to match [blue, seven] ignoring order of elements',
'Expected "seven" to match \'red|blue\'']
"Expected 'seven' to match 'red|blue'"]
mismatches*.path == ['$', '$.1']
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ class KafkaJsonSchemaContentMatcherSpec extends Specification {
then:
!mismatches.empty
mismatches*.mismatch == ['Expected [red, blue] to match [blue, seven] ignoring order of elements',
'Expected "seven" to match \'red|blue\'']
"Expected 'seven' to match 'red|blue'"]
mismatches*.path == ['$', '$.1']
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class MatchingContextSpec extends Specification {

then:
!mismatches.empty
mismatches*.mismatch == ['Expected "200.3" (String) to be the same type as 100 (Integer)']
mismatches*.mismatch == ["Expected '200.3' (String) to be the same type as 100 (Integer)"]
}

def 'type matcher - match on type - map elements should inherit the matchers from the parent'() {
Expand All @@ -183,7 +183,7 @@ class MatchingContextSpec extends Specification {

then:
!mismatches.empty
mismatches*.mismatch == ['Expected "200.3" (String) to be the same type as 100 (Integer)']
mismatches*.mismatch == ["Expected '200.3' (String) to be the same type as 100 (Integer)"]
}

def 'path matching - match root node'() {
Expand Down

0 comments on commit 68b8822

Please sign in to comment.