Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigToYamlData(cfg interface{}, appCfgType reflect.Type) ([]byte, error)
- func CreateServiceWithTestHooksPatched(createService interface{}, testHooks *core.Hooks) interface{}
- func GetResponseBodyAndClose(b io.ReadCloser) []byte
- func GetTestLine() string
- type Endpoint
- type ResponseTest
- type TestCall
- type TestCall2
- type Tester
- func (b *Tester) BuildID() string
- func (b *Tester) BuildMetadata() *status.BuildMetadata
- func (b *Tester) CfgBasePath() string
- func (b *Tester) Close()
- func (b *Tester) Do(tc TestCall)
- func (b *Tester) Do2(tc TestCall2)
- func (b *Tester) EndpointURL(suffix string) string
- func (b *Tester) GetBufDialer(context.Context, string) (net.Conn, error)
- func (b *Tester) GetName() string
- func (b *Tester) GracefulStop() error
- func (b *Tester) HTTPClientGetter(host string) (*http.Client, string, error)
- func (b *Tester) NewDownstream(host, method, path string) Endpoint
- func (b *Tester) Start() error
- func (b *Tester) Stop() error
- func (b *Tester) T() syslgo.TestingT
- type Tests
- func ExpectBody(expected []byte) Tests
- func ExpectHeaders(headers map[string]string, checkForExtra ...bool) Tests
- func ExpectHeadersDoNotExist(headers []string) Tests
- func ExpectHeadersExist(headers []string) Tests
- func ExpectHeadersExistExactly(headers []string) Tests
- func ExpectJSONBody(expected []byte) Tests
- func ExpectQueryParams(query map[string][]string) Tests
- func ExpectURLParam(key string, expected string) Tests
- func ExpectURLParamForInt(key string, expected int64) Tests
- func ForceDownstreamTimeout() Tests
- func Response(code int, headers map[string]string, body []byte) Tests
Constants ¶
const (
ContentTypeKey = "Content-Type"
)
const ( // DownstreamTimeout is only used for mocked downstreams, and is as small as possible to make the timeout tests // quicker, but give them time to actually succeed. DownstreamTimeout = time.Millisecond * 400 )
Variables ¶
var IgnoreHeaders = []string{}
IgnoreHeaders is a list of headers that should be ignored during testing.
Functions ¶
func ConfigToYamlData ¶
func CreateServiceWithTestHooksPatched ¶
func CreateServiceWithTestHooksPatched(createService interface{}, testHooks *core.Hooks) interface{}
CreateServiceWithTestHooksPatched will return a function with the same signature as createService but will patch the test hooks into the result (we don't know the config type at this point so use reflection).
func GetResponseBodyAndClose ¶
func GetResponseBodyAndClose(b io.ReadCloser) []byte
func GetTestLine ¶
func GetTestLine() string
Types ¶
type ResponseTest ¶ added in v0.248.0
func ExpectResponseHeaders ¶ added in v0.248.0
func ExpectResponseHeaders(headers map[string]string, checkForExtra ...bool) ResponseTest
ExpectResponseHeaders: Expects the given headers and their values exist in the response. checkForExtra is an optional parameter to check for extra headers not expected.
func ExpectResponseHeadersDoNotExist ¶ added in v0.248.0
func ExpectResponseHeadersDoNotExist(headers []string) ResponseTest
ExpectResponseHeadersDoNotExist: Expects the given header names cannot be found in the response.
func ExpectResponseHeadersExist ¶ added in v0.248.0
func ExpectResponseHeadersExist(headers []string) ResponseTest
ExpectResponseHeadersExist: Expects the given header names can be found in the response.
func ExpectResponseHeadersExistExactly ¶ added in v0.248.0
func ExpectResponseHeadersExistExactly(headers []string) ResponseTest
ExpectResponseHeadersExistExactly: Expects the given headers in the response exist (and no others).
type Tester ¶
type Tester struct {
// contains filtered or unexported fields
}
func (*Tester) BuildMetadata ¶
func (b *Tester) BuildMetadata() *status.BuildMetadata
func (*Tester) CfgBasePath ¶
func (*Tester) EndpointURL ¶
func (*Tester) GetBufDialer ¶ added in v0.230.0
func (*Tester) GracefulStop ¶
func (*Tester) HTTPClientGetter ¶
func (*Tester) NewDownstream ¶
type Tests ¶
func ExpectBody ¶
func ExpectHeaders ¶
ExpectHeaders: Expects the given headers and their values exist in the response. checkForExtra is an optional parameter to check for extra headers not expected.
func ExpectHeadersDoNotExist ¶
ExpectHeadersDoNotExist: Expects the given header names cannot be found in the response.
func ExpectHeadersExist ¶
ExpectHeadersExist: Expects the given header names can be found in the response.
func ExpectHeadersExistExactly ¶
ExpectHeadersExistExactly: Expects the given headers in the response exist (and no others).
func ExpectJSONBody ¶
func ExpectQueryParams ¶
func ExpectURLParam ¶ added in v0.223.0
func ExpectURLParamForInt ¶ added in v0.223.0
func ForceDownstreamTimeout ¶
func ForceDownstreamTimeout() Tests