mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 18:47:38 +01:00
Refactor make dependent fixtures to use built in scalatest helper met… (#939)
* Refactor make dependent fixtures to use built in scalatest helper methods * Avoid unit return warning
This commit is contained in:
parent
2c53a39fd1
commit
2bdbc1c822
1 changed files with 6 additions and 21 deletions
|
@ -32,33 +32,18 @@ trait BitcoinSFixture extends BitcoinSAsyncFixtureTest {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
|
|
||||||
val outcomeF = fixtureF.flatMap { fixture =>
|
val outcomeF: Future[Outcome] = fixtureF.flatMap { fixture =>
|
||||||
test(fixture.asInstanceOf[FixtureParam]).toFuture
|
test(fixture.asInstanceOf[FixtureParam]).toFuture
|
||||||
}
|
}
|
||||||
|
|
||||||
outcomeF.failed.foreach(err =>
|
val futOutcome: FutureOutcome = new FutureOutcome(outcomeF)
|
||||||
println(s"Failed fixture test execution=${err}"))
|
|
||||||
|
|
||||||
val destroyP = Promise[Unit]()
|
val result: FutureOutcome = futOutcome.onOutcomeThen { _ =>
|
||||||
outcomeF.onComplete { _ =>
|
fixtureF.flatMap(f => destroy(f))
|
||||||
fixtureF.foreach { fixture =>
|
()
|
||||||
destroy(fixture).onComplete {
|
|
||||||
case Success(_) => destroyP.success(())
|
|
||||||
case Failure(err) =>
|
|
||||||
logger.error(s"Failed to destroy fixture with err=${err}")
|
|
||||||
destroyP.failure(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val outcomeAfterDestroyF = destroyP.future.flatMap(_ => outcomeF)
|
result
|
||||||
|
|
||||||
outcomeAfterDestroyF.failed.foreach { err =>
|
|
||||||
println(s"err creating and destroying fixture")
|
|
||||||
throw err
|
|
||||||
|
|
||||||
}
|
|
||||||
new FutureOutcome(outcomeAfterDestroyF)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue