Skip to content

Instantly share code, notes, and snippets.

@erip
Created January 2, 2018 14:10
Show Gist options
  • Save erip/7439e8c6ef853eda69487915986e9a14 to your computer and use it in GitHub Desktop.
Save erip/7439e8c6ef853eda69487915986e9a14 to your computer and use it in GitHub Desktop.
`withClient` example
import com.lightbend.lagom.scaladsl.testkit.ServiceTest._
private def withDefaultClient(testCode: (MyService) => Any): Unit = {
withServer(ServiceTest.defaultSetup) { ctx =>
new MyApplication(ctx) with LocalServiceLocator {
// whatever your Application Cake should look like...
}
} { server =>
// Client for your service
val client = server.serviceClient.implement[MyService]
testCode(client)
// Sleep so cassandra can drop keys and restart...
Thread.sleep(1000)
}
}
@erip
Copy link
Author

erip commented Jan 2, 2018

Usage

"MyService" should "do something" in withDefaultClient { client =>
  assert(client.canDoSomething)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment