testr

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxConcurrentTests = 5
)

Variables

This section is empty.

Functions

func BaseURLFromContext

func BaseURLFromContext(ctx context.Context) string

BaseURLFromContext returns the base URL to be used in tests, as stored in the given context

func ContextWithBaseURL

func ContextWithBaseURL(ctx context.Context, baseURL string) context.Context

ContextWithBaseURL stores the given base URL in the context

func ContextWithCustomBodyCheck

func ContextWithCustomBodyCheck(ctx context.Context, checkID string, checkFunc check.BodyCustomCheckerFunc) context.Context

ContextWithCustomBodyCheck stores a BodyCustomCheckerFunc into the context under the given id

func ContextWithRequestInitFunc

func ContextWithRequestInitFunc(ctx context.Context, initFuncID string, requestInitFunc RequestInitFunc) context.Context

ContextWithRequestInitFunc stores a RequestInitFunc into the context under the given id

func CustomBodyCheckFromContext

func CustomBodyCheckFromContext(ctx context.Context, checkID string) check.BodyCustomCheckerFunc

CustomBodyCheckFromContext retrieves a BodyCustomCheckerFunc from the context by id

func RequestBodyReplacements added in v0.0.6

func RequestBodyReplacements(ctx context.Context, req *http.Request, data map[string]interface{}) (*http.Request, error)

RequestBodyReplacements runs a find and replace in the request body with the given replacements in `data`

func RequestHeaderReplacements added in v0.0.6

func RequestHeaderReplacements(ctx context.Context, req *http.Request, data map[string]interface{}) (*http.Request, error)

RequestHeaderReplacements runs a find and replace in the request headers with the given replacements in `data`

func RequestReplacements added in v0.0.6

func RequestReplacements(ctx context.Context, req *http.Request, data map[string]interface{}) (*http.Request, error)

RequestReplacements runs a find and replace in the request body, headers and url path with the given replacements in `data`

func RequestURLReplacements added in v0.0.11

func RequestURLReplacements(ctx context.Context, req *http.Request, data map[string]interface{}) (*http.Request, error)

RequestSchemeReplacements runs a find and replace in the request url scheme with the given replacements in `data`

func Run

func Run(ctx context.Context, t *Test, httpClient *http.Client, logger *log.Logger) error

Run executes a single test

Types

type RequestInitFunc

type RequestInitFunc func(ctx context.Context, req *http.Request, data map[string]interface{}) (*http.Request, error)

RequestInitFunc defines the structure of the functions that can be used to initialise a request

func RequestInitFuncFromContext

func RequestInitFuncFromContext(ctx context.Context, initFuncID string) RequestInitFunc

RequestInitFuncFromContext retrieves a RequestInitFunc from the context by id

type RunAllArgs

type RunAllArgs struct {
	HTTPClient         *http.Client
	MaxConcurrentTests int
	Logger             *log.Logger
	// If Groups is not nil, only tests belonging to one of these groups will be executed
	Groups []string
	// If IgnoreGroups is not nil, any tests belonging to one of these groups will not be executed
	IgnoreGroups []string
	// IgnoreAllOnFailure should be true if when a test fails you want no more tests to be executed
	IgnoreAllOnFailure bool
	// IgnoreGroupOnFailure should be true if when a test fails you want no more tests in the failed group to be executed
	IgnoreGroupOnFailure bool
}

RunAllArgs defines which arguments are available to give to RunAll

type RunAllResult

type RunAllResult struct {
	Executed int
	Passed   int
	Failed   int
	Skipped  int
}

RunAllResult is the response given from RunAll

func RunAll

func RunAll(ctx context.Context, args RunAllArgs, tests ...*Test) RunAllResult

RunAll runs the set of given tests

type Test

type Test struct {
	// Name is the name of the test
	Name string
	// Group is the group that the test belongs to
	Group string
	// Order specified the order in which it will be run. Tests with the same order will be executed at the same time
	Order int
	// Checks contains all checks contained in this test
	Checks []check.Checker
	// Request contains the http request being made
	Request *http.Request
	// Response contains the http response
	Response *http.Response
	// RequestInitFuncs contains a set of functions used to initialise the request
	RequestInitFuncs []RequestInitFunc
	// RequestInitFuncsData contains the arguments to be given to the init func with the matching index
	RequestInitFuncsData []map[string]interface{}
}

Test defines a test for a single endpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL