Documentation
¶
Index ¶
- type IncomingRequest
- type MockResponse
- type MockServer
- func (s *MockServer) DEFAULT() RequestExpectation
- func (s *MockServer) EVERY() RequestExpectation
- func (s *MockServer) EXPECT() RequestExpectation
- func (s *MockServer) Finish()
- func (s *MockServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *MockServer) Shutdown()
- func (s *MockServer) URL() string
- type Opts
- type RequestExpectation
- type RequestValidationFunc
- type ResponseExpectation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IncomingRequest ¶
type IncomingRequest struct {
// contains filtered or unexported fields
}
type MockServer ¶
type MockServer struct {
// contains filtered or unexported fields
}
func New ¶
func New(t *testing.T) *MockServer
func NewWithOpts ¶ added in v0.2.0
func NewWithOpts(t *testing.T, opts Opts) *MockServer
func (*MockServer) DEFAULT ¶ added in v0.2.0
func (s *MockServer) DEFAULT() RequestExpectation
func (*MockServer) EVERY ¶
func (s *MockServer) EVERY() RequestExpectation
TODO: response expectation makes no sense here
func (*MockServer) EXPECT ¶
func (s *MockServer) EXPECT() RequestExpectation
func (*MockServer) Finish ¶
func (s *MockServer) Finish()
func (*MockServer) ServeHTTP ¶
func (s *MockServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*MockServer) Shutdown ¶
func (s *MockServer) Shutdown()
func (*MockServer) URL ¶ added in v0.2.0
func (s *MockServer) URL() string
type RequestExpectation ¶
type RequestExpectation interface {
AnyRequest() RequestExpectation
AnyTimes() RequestExpectation
Times(n int) RequestExpectation
MinTimes(n int) RequestExpectation
MaxTimes(n int) RequestExpectation
Request(method string, path string) RequestExpectation
Method(method string) RequestExpectation
Path(path string) RequestExpectation
PathRegex(pathRegex string) RequestExpectation
GET() RequestExpectation
POST() RequestExpectation
PUT() RequestExpectation
DELETE() RequestExpectation
Get(path string) RequestExpectation
Post(path string) RequestExpectation
Put(path string) RequestExpectation
Delete(path string) RequestExpectation
Header(key, value string) RequestExpectation
Headers(map[string]string) RequestExpectation
BasicAuth(user, password string) RequestExpectation
Custom(validation RequestValidationFunc, description string) RequestExpectation
JsonBody(object interface{}) RequestExpectation
StringBody(body string) RequestExpectation
Body(body []byte) RequestExpectation
BodyFunc(func(body []byte) error) RequestExpectation
// switch to responseExpectations
Response(code int) ResponseExpectation
}
type RequestValidationFunc ¶
type RequestValidationFunc func(r *IncomingRequest) error
type ResponseExpectation ¶
type ResponseExpectation interface {
Header(key, value string) ResponseExpectation
Headers(headers map[string]string) ResponseExpectation
StringBody(body string) ResponseExpectation
JsonBody(object interface{}) ResponseExpectation
Body(data []byte) ResponseExpectation
}
Click to show internal directories.
Click to hide internal directories.