Skip to content

Commit

Permalink
Fix eventually statements (#1835)
Browse files Browse the repository at this point in the history
With the move to akka _typed_, we will be using more and more
scalatest's `eventually` as a replacement for akka's `awaitCond`
(which isn't available in `testkit.typed`).

But there is a catch:
- `awaitCond` expects a boolean
- `eventually` expects a non-failure

Which means that we must use `eventually(assert(cond))`, and not
`eventually(cond)`.
  • Loading branch information
pm47 committed Jun 7, 2021
1 parent 2b6d564 commit bd6bad1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PgUtilsSpec extends TestKitBaseClass with AnyFunSuiteLike with Eventually

// we close the first connection
db.dataSource.close()
eventually(db.dataSource.isClosed)
eventually(assert(db.dataSource.isClosed))
// we wait just a bit longer than the lease interval
Thread.sleep(6_000)

Expand All @@ -52,7 +52,7 @@ class PgUtilsSpec extends TestKitBaseClass with AnyFunSuiteLike with Eventually

// we close the second connection
db.dataSource.close()
eventually(db.dataSource.isClosed)
eventually(assert(db.dataSource.isClosed))

// but we don't wait for the previous lease to expire, so we can't take over right now
assert(intercept[LockFailureHandler.LockException] {
Expand All @@ -73,7 +73,7 @@ class PgUtilsSpec extends TestKitBaseClass with AnyFunSuiteLike with Eventually

// we close the first connection
db.dataSource.close()
eventually(db.dataSource.isClosed)
eventually(assert(db.dataSource.isClosed))

// here we change the config to simulate an involuntary change in the server we connect to
val config1 = ConfigFactory.parseString("postgres.port=1234").withFallback(config)
Expand Down

0 comments on commit bd6bad1

Please sign in to comment.