In order to facilitate testing and make service box easier to use in such context, one could provide a set of methods in order to reduce boilerplate.
I propose something like the following methods:
def withServicesUp[F[_]](specs: Spec[F] *)(f: Map[(Service.Ref, Port), Location] => F) : Unit
def withServicesUpUnsafe[F, R](specs: Spec[F] *)(f: Map[(Service.Ref, Port), Location] => R) : Unit
These methods would essentially
- start the application
- wait for all services to be healthy
- Attempt to run the test defined by
f
- Cleanup the docker state (stopping && removing containers )
- Propagate the effect final result back to the testing framework
This would potentially allow users to create tests as following
def withApp = ??? //some code that start my application under test
"My app" when "ready" should withServiceBoxUp { config =>
val dbPort = config(Postgres.ref, Port(5432)).port
"obey a rule" withApp(config) { app =>
//testCode goes here
}
"obey another rule" withApp(config) { app =>
//testCode goes here
}
}
Because we don't want these to clutter the current modules of service box I would also propose adding them in a separate module.
In order to facilitate testing and make service box easier to use in such context, one could provide a set of methods in order to reduce boilerplate.
I propose something like the following methods:
These methods would essentially
fThis would potentially allow users to create tests as following
Because we don't want these to clutter the current modules of service box I would also propose adding them in a separate module.