Documentation ¶
Index ¶
- Variables
- func Assert(tb testing.TB, condition bool, msg string, v ...interface{})
- func Equals(tb testing.TB, exp, act interface{})
- func Fixture(path string) string
- func NewHttpClient(fn RoundTripFunc) *http.Client
- func Ok(tb testing.TB, err error)
- func Register[T any](name string, value T) T
- func RegisterEndpoint(endpoint string, responseWriter ResponseWriter, ...) string
- func RegisterPaginatedEndpoint(t *testing.T, url string, requests ...TestRequest) string
- func RunTableTests[T any](t *testing.T, cases map[string]T, fn func(*testing.T, T))
- func Setup() func()
- func TemplatedFixture(fixture string) string
- func ToJson(query GraphqlQuery) string
- type FixtureTemplater
- type GraphqlQuery
- type RequestValidation
- func GraphQLQueryFixtureValidation(t *testing.T, fixture string) RequestValidation
- func GraphQLQueryToJsonValidation(t *testing.T, request GraphqlQuery) RequestValidation
- func GraphQLQueryValidation(t *testing.T, exp string) RequestValidation
- func SkipRequestValidation() RequestValidation
- func TestRequestValidation(t *testing.T, request TestRequest) RequestValidation
- type ResponseWriter
- type RoundTripFunc
- type TestRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Mux *http.ServeMux Server *httptest.Server Templater *FixtureTemplater )
Functions ¶
func RegisterEndpoint ¶
func RegisterEndpoint(endpoint string, responseWriter ResponseWriter, requestValidation RequestValidation) string
func RegisterPaginatedEndpoint ¶ added in v2023.12.7
func RegisterPaginatedEndpoint(t *testing.T, url string, requests ...TestRequest) string
func RunTableTests ¶ added in v2023.11.2
RunTableTests runs a table of tests calling `fn` for each test and ensuring all tests run in parallel using goroutines
func Setup ¶
func Setup() func()
Setup an HttpTestServer and ServerMux (for path routing) and return the teardown function
func TemplatedFixture ¶
func ToJson ¶
func ToJson(query GraphqlQuery) string
Types ¶
type FixtureTemplater ¶
type FixtureTemplater struct {
// contains filtered or unexported fields
}
func NewFixtureTemplater ¶
func NewFixtureTemplater(templateDirs ...string) *FixtureTemplater
NewFixtureTemplater creates a FixtureTemplater using the templates load from the passed in templateDir
If no templateDir is passed in then ./testdata/templates is used
func (*FixtureTemplater) ParseToBytes ¶ added in v2023.12.7
func (t *FixtureTemplater) ParseToBytes(contents string) (*bytes.Buffer, error)
type GraphqlQuery ¶
func GraphQLQueryFixture ¶
func GraphQLQueryFixture(fixture string) GraphqlQuery
func Parse ¶
func Parse(r *http.Request) GraphqlQuery
type RequestValidation ¶
func GraphQLQueryFixtureValidation ¶
func GraphQLQueryFixtureValidation(t *testing.T, fixture string) RequestValidation
func GraphQLQueryToJsonValidation ¶ added in v2023.12.6
func GraphQLQueryToJsonValidation(t *testing.T, request GraphqlQuery) RequestValidation
func GraphQLQueryValidation ¶
func GraphQLQueryValidation(t *testing.T, exp string) RequestValidation
func SkipRequestValidation ¶
func SkipRequestValidation() RequestValidation
func TestRequestValidation ¶ added in v2023.12.7
func TestRequestValidation(t *testing.T, request TestRequest) RequestValidation
type ResponseWriter ¶
type ResponseWriter func(http.ResponseWriter)
func EmptyResponse ¶
func EmptyResponse() ResponseWriter
func FixtureResponse ¶
func FixtureResponse(fixture string) ResponseWriter
func JsonStringResponse ¶ added in v2023.12.6
func JsonStringResponse(jsonString string) ResponseWriter
func TestRequestResponse ¶ added in v2023.12.7
func TestRequestResponse(testRequest TestRequest) ResponseWriter
type RoundTripFunc ¶
type TestRequest ¶ added in v2023.12.6
type TestRequest struct { Request GraphqlQuery Response map[string]any }
func NewTestRequest ¶ added in v2023.12.6
func NewTestRequest(request string, variables string, response string) TestRequest
func (*TestRequest) ResponseAsString ¶ added in v2023.12.7
func (t *TestRequest) ResponseAsString() string
Click to show internal directories.
Click to hide internal directories.