Skip to content

Commit

Permalink
Make publish message test more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Jun 1, 2023
1 parent a25f5f4 commit 72e4e9b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,22 @@ object ScalaKernelTests extends TestSuite {
)

val expectedPublishMessageTypes = Seq(
"execute_input",
"display_data",
"execute_input",
"update_display_data",
"execute_input",
"update_display_data"
Set(
"execute_input",
"display_data"
),
Set(
"execute_input",
"update_display_data"
),
Set(
"execute_input",
"update_display_data"
)
)

assert(requestsMessageTypes == expectedRequestsMessageTypes)
assert(publishMessageTypes == expectedPublishMessageTypes)
TestUtil.comparePublishMessageTypes(expectedPublishMessageTypes, publishMessageTypes)

val displayData = streams.displayData.map {
case (d, b) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,13 @@ object TestUtil {
}
}

def comparePublishMessageTypes(expected: Seq[Set[String]], got: Seq[String]): Boolean =
expected.map(_.size).sum == got.length && {
val it = got.iterator
expected.forall { expectedGroup =>
val got0 = it.take(expectedGroup.size).toSet
expectedGroup == got0
}
}

}

0 comments on commit 72e4e9b

Please sign in to comment.