Documentation
¶
Index ¶
- Variables
- func AssertResponse(resp *http.Response, tc *TestCase) error
- func Cert(domain string) tls.Certificate
- func HttpHandlerRunner(handler http.HandlerFunc) func(*http.Request, *TestCase) (*http.Response, error)
- func HttpServerRequestBuilder(baseURL string) func(tc *TestCase) (*http.Request, error)
- func HttpServerRunner() func(*http.Request, *TestCase) (*http.Response, error)
- func IsDnsRecordsAddrsEqualsTo(itemAddrs, addrs []string) bool
- func NewRequest(tc *TestCase) (req *http.Request, err error)
- func ReqBodyReader(body interface{}) io.Reader
- func TcpMock(useSSL bool, cb func(in []byte, err error) (out []byte)) net.Listener
- func TestHttpHandler(t testing.TB, handle http.HandlerFunc, testCases ...TestCase)
- func TestHttpServer(t testing.TB, baseURL string, testCases ...TestCase)
- type DnsMockHandle
- type HTTPTestRunner
- type TCPTestCase
- type TCPTestRunner
- type TestCase
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DomainsToAddresses = map[string][]string{ "host1.": {"127.0.0.1"}, "host2.": {"127.0.0.1"}, "host3.": {"127.0.0.1"}, } DomainsToIgnore = []string{ "redis.", "tyk-redis.", "mongo.", "tyk-mongo.", } )
Functions ¶
func HttpHandlerRunner ¶
func HttpServerRunner ¶
func ReqBodyReader ¶
func TestHttpHandler ¶
func TestHttpHandler(t testing.TB, handle http.HandlerFunc, testCases ...TestCase)
Types ¶
type DnsMockHandle ¶
type DnsMockHandle struct {
ShutdownDnsMock func() error
// contains filtered or unexported fields
}
func InitDNSMock ¶
func InitDNSMock(domainsMap map[string][]string, domainsErrorMap map[string]int) (*DnsMockHandle, error)
InitDNSMock initializes dns server on udp:0 address and replaces net.DefaultResolver in order to route all dns queries within tests to this server. InitDNSMock returns handle, which can be used to add/remove dns query mock responses or initialization error.
func (*DnsMockHandle) PushDomains ¶
func (h *DnsMockHandle) PushDomains(domainsMap map[string][]string, domainsErrorMap map[string]int) func()
type HTTPTestRunner ¶
type TCPTestCase ¶
type TCPTestRunner ¶
func (TCPTestRunner) Run ¶
func (r TCPTestRunner) Run(t testing.TB, testCases ...TCPTestCase) error
type TestCase ¶
type TestCase struct {
Method string `json:",omitempty"`
Path string `json:",omitempty"`
BaseURL string `json:",omitempty"`
Domain string `json:",omitempty"`
Proto string `json:",omitempty"`
Code int `json:",omitempty"`
Data interface{} `json:",omitempty"`
Headers map[string]string `json:",omitempty"`
PathParams map[string]string `json:",omitempty"`
FormParams map[string]string `json:",omitempty"`
Cookies []*http.Cookie `json:",omitempty"`
Delay time.Duration `json:",omitempty"`
BodyMatch string `json:",omitempty"` // regex
BodyMatchFunc func([]byte) bool `json:",omitempty"`
BodyNotMatch string `json:",omitempty"`
HeadersMatch map[string]string `json:",omitempty"`
HeadersNotMatch map[string]string `json:",omitempty"`
JSONMatch map[string]string `json:",omitempty"`
ErrorMatch string `json:",omitempty"`
BeforeFn func() `json:"-"`
Client *http.Client `json:"-"`
AdminAuth bool `json:",omitempty"`
ControlRequest bool `json:",omitempty"`
}
Click to show internal directories.
Click to hide internal directories.