Documentation ¶
Index ¶
- func CtxWithMock(ctx context.Context, mock ...*Mock) context.Context
- func InitMockSetting()
- func WithHeader(key, value string) simpleConditionOption
- func WithJsonBodyFields(field string, value interface{}) simpleConditionOption
- func WithMethod(method string) simpleConditionOption
- func WithPathReg(pathReg string) simpleConditionOption
- func WithQuery(key, value string) simpleConditionOption
- type Mock
- type MockResponseFilter
- type RequestCondition
- type SimpleCondition
- type Stub
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitMockSetting ¶
func InitMockSetting()
func WithHeader ¶
func WithHeader(key, value string) simpleConditionOption
func WithJsonBodyFields ¶
func WithJsonBodyFields(field string, value interface{}) simpleConditionOption
func WithMethod ¶
func WithMethod(method string) simpleConditionOption
func WithPathReg ¶
func WithPathReg(pathReg string) simpleConditionOption
Types ¶
type MockResponseFilter ¶
type MockResponseFilter struct {
// contains filtered or unexported fields
}
MockResponse will return mock response if find any suitable mock data if you want to test your code using httplib, you need this.
func NewMockResponseFilter ¶
func NewMockResponseFilter() *MockResponseFilter
func (*MockResponseFilter) Clear ¶
func (m *MockResponseFilter) Clear()
func (*MockResponseFilter) FilterChain ¶
func (m *MockResponseFilter) FilterChain(next httplib.Filter) httplib.Filter
func (*MockResponseFilter) Mock ¶
func (m *MockResponseFilter) Mock(cond RequestCondition, resp *http.Response, err error)
Mock add mock data If the cond.Match(...) = true, the resp and err will be returned
func (*MockResponseFilter) MockByPath ¶
func (m *MockResponseFilter) MockByPath(path string, resp *http.Response, err error)
type RequestCondition ¶
type RequestCondition interface {
Match(ctx context.Context, req *httplib.BeegoHTTPRequest) bool
}
type SimpleCondition ¶
type SimpleCondition struct {
// contains filtered or unexported fields
}
reqCondition create condition - path: same path - pathReg: request path match pathReg - method: same method - Query parameters (key, value) - header (key, value) - Body json format, contains specific (key, value).
func NewSimpleCondition ¶
func NewSimpleCondition(path string, opts ...simpleConditionOption) *SimpleCondition
func (*SimpleCondition) Match ¶
func (sc *SimpleCondition) Match(ctx context.Context, req *httplib.BeegoHTTPRequest) bool
Click to show internal directories.
Click to hide internal directories.