Documentation ¶
Index ¶
- func Assert(t *testing.T, boolStatement bool, errorValue interface{})
- func CheckResources(haps ...HostAndPort) error
- func IntegrationDBTestSetup(t *testing.T, db *sql.DB) (func(t *testing.T, db *sql.DB), error)
- func IntegrationDBTestSetupMain(db *sql.DB) (func(db *sql.DB), error)
- type HostAndPort
- type TestClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Assert checks that the boolean statement is true. If not, it fails the test with the given error value. Assert streamlines test checks.
func CheckResources ¶
func CheckResources(haps ...HostAndPort) error
CheckResources ensures that any resources needed for an integration test are available. If a resource is not available, it returns an error.
func IntegrationDBTestSetup ¶
IntegrationDBTestSetup ensures that the database is empty before running any tests and returns a teardown function that will delete all entries in the database.
Types ¶
type HostAndPort ¶
HostAndPort holds the host and port information for a resource.
type TestClient ¶
TestClient is test wrapper around an http client, allowing http responses to be mocked.
func NewTestClient ¶
func NewTestClient(handler http.Handler) *TestClient
NewTestClient creates a new TestClient using an httptest TLS Server. Any http requests using this client will be handled by 'handler'.
func NewTestClientNoTLS ¶
func NewTestClientNoTLS(handler http.Handler) *TestClient
func NewTestClientWith404 ¶
func NewTestClientWith404() *TestClient
NewTestClientWith404 creates a new TestClient using an httptest TLS Server, and requests are responded to with a 404 response code.
func NewTestClientWith406 ¶
func NewTestClientWith406() *TestClient
NewTestClientWith406 creates a new TestClient using an httptest TLS Server, and requests are responded to with a 406 response code.
func NewTestClientWith502 ¶
func NewTestClientWith502() *TestClient
NewTestClientWith502 creates a new TestClient using an httptest TLS Server, and requests are responded to with a 502 response code.
func NewTestClientWithResponse ¶
func NewTestClientWithResponse(response []byte) *TestClient
NewTestClientWithResponse creates a new TestClient using an httptest TLS Server, and requests are responded to using the given response byte string.
func (*TestClient) Close ¶
func (tc *TestClient) Close()
Close closes resources associated with the test client and should be called after every instantiation of the client.