Skip to content

Adding scala test integration for servicebox #9

Description

@cmcmteixeira

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

  1. start the application
  2. wait for all services to be healthy
  3. Attempt to run the test defined by f
  4. Cleanup the docker state (stopping && removing containers )
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions