Documentation ¶
Overview ¶
package harness contains functionality for setting up and testing the coordinator in various different states. This includes full integration tests and smaller unit tests
Index ¶
Constants ¶
const AdminEmail = models.Email("admin@cape.com")
const AdminName = models.Name("admin")
const AdminPassword = "iamtheadmin"
Variables ¶
var ( TimeoutCause = errors.NewCause(errors.RequestTimeoutCategory, "start_timeout") NotStartedCause = errors.NewCause(errors.BadRequestCategory, "coordinator_not_started") )
var (
MissingConfig = errors.NewCause(errors.BadRequestCategory, "missing_config")
)
Functions ¶
func TestLogger ¶ added in v0.0.2
TestLogger returns a logger for use in writing tests
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the configuration required to create a Coordinator Harness
func (*Config) Migrations ¶
Migrations returns a list of directories containing migrations
type Harness ¶
type Harness struct {
// contains filtered or unexported fields
}
Harness represents a http server used for testing. Its responsibility is to provide the transport layer for the application contained within the component. In this case, the component represents a Coordinator.
This is a convenience layer for testing the Coordinator by spinning up a database, migrating it, running the tests, tearing them down, and then cleaning any remaining artifacts up.
This harness uses net/http/httptest.Server so it will start the server on a randomized port that has not yet been assigned.
This harness _does not_ manage any client state or actually "setup" the coordinator admin functionality. Please see the harness.Manager which provides convenience functions for managing application state.
You can use it as follows:
h, err := NewHarness(cfg) if err != nil { return err // Handle your errors! } err = h.Setup(ctx) ... defer h.Teardown()
func NewHarness ¶
NewHarness returns a new harness that's configured and ready to be setup!
func (*Harness) Client ¶
func (h *Harness) Client() (*coordinator.Client, error)
Client returns an unauthenticated Client for the underlying instance of the coordinator.
type Manager ¶
type Manager struct { Admin *User // contains filtered or unexported fields }
Manager represents an application state manager on-top of the Coordinator's harness. It's job is to provide convenience functions for setting up a coordinator's application state, managing users, and other utilities that make it write end-to-end integration tests.