-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support given state for service testing #1424
Comments
I'm 100% onboard when discussing improvements on For the particular case you described would a small refactor suffice?
|
@ignasi35 I think it would be nice if that interface were provided by Lagom. What do you think? |
Are you thinking about a (I was thinking about business-aware interfaces that completely abstract the |
I think my idea was a combination of the two. 😄The in-memoryness would allow for more control over the API (and less dependence on what the backing store is), but it would still be business-aware since the service would interact with it the same way. Maybe there's a better way to do this, though. |
When testing services (as opposed to persistent entities), it's currently necessary to do a lot of expensive setup to set up state against which to make assertions.
Consider the case where you want to test
GET /api/foos/:id
. In order to test this, you must first necessarily add afoo
, then use the returned ID to test this endpoint. This has a few problems:Lagom should support some way to provide a golden state in
TestServer
. One approach might to be to play a series of events against a clean DB (similar to PE tests).One workaround would be to support a callback which supports issuing a series of "setup" invocations againt a
FooClient
and maintains a map between a "gold state" artifacts (e.g., some given foo ID) and the test-generated artifacts (e.g., returned foo ID from a create call). This is quite cumbersome and slow, but doesn't require a huge amount of work, I think.The text was updated successfully, but these errors were encountered: