diff --git a/src/test/scala/cromwell/engine/db/slick/SlickDataAccessSpec.scala b/src/test/scala/cromwell/engine/db/slick/SlickDataAccessSpec.scala index 928cebabf19..0a6582861af 100644 --- a/src/test/scala/cromwell/engine/db/slick/SlickDataAccessSpec.scala +++ b/src/test/scala/cromwell/engine/db/slick/SlickDataAccessSpec.scala @@ -222,11 +222,16 @@ class SlickDataAccessSpec extends FlatSpec with Matchers with ScalaFutures { } def assertCallCachingFailure(id: WorkflowId, callName: Option[String], messages: String*): Future[Unit] = { - // The `from` Future is expected to fail, so if the `map` block runs the test should fail. `recover` the - // failed Future and assert all the expected messages are present in the exception text and the correct number - // of expected failures are seen. - CallCachingParameters.from(id, None, AllowFalse, dataAccess) map { - s => throw new RuntimeException(s"Unexpected success: $s") } recover { + // The `from` Future is expected to fail, so if the forcomp actually runs the test should fail. + val parameters = for { + s <- CallCachingParameters.from(id, None, AllowFalse, dataAccess) + } yield throw new RuntimeException(s"Unexpected success: $s") + + // `recover` the failed Future looking for an expected `IllegalArgumentException`. Assert all the expected + // messages are present in the exception text and the correct number of expected failures are seen. + // If the `parameters` Future is failed but the exception isn't an `IllegalArgumentException` then this recover + // won't match and the Future will remain failed and fail the test. + parameters recover { case e: IllegalArgumentException => messages foreach { m => if (!e.getMessage.contains(m)) throw new RuntimeException(s"Missing message: $m. Exception text: ${e.getMessage}") } if (e.getMessage.count(_ == '\n') != messages.size - 1) throw new RuntimeException(s"Unexpected messages seen: ${e.getMessage}")