Skip to content

Commit

Permalink
test for suprresed teardown exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvgica committed Nov 25, 2021
1 parent d0bfbca commit 419f63c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion managerial/src/test/scala/ca/dvgi/managerial/ManagedTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,21 @@ class ManagedTest extends munit.FunSuite {
_ <- Managed.evalSetup(throw setupException)
} yield ()

interceptMessage[RuntimeException](setupException.getMessage) {
try {
m.build()
} catch {
case t: RuntimeException =>
assertEquals(t.getMessage, setupException.getMessage)
assertEquals(t.getSuppressed.size, 1)
t.getSuppressed()(0) match {
case te: RuntimeException =>
assertEquals(
te.getMessage,
teardownException.getMessage
)
case e => fail("Unexpected exception", e)
}
case _: Throwable => fail("Unexpected exception")
}
}
}

0 comments on commit 419f63c

Please sign in to comment.