Documentation ¶
Overview ¶
Package apitest Usage:
NewAT(xxx). SetParam(xxx). Debug(). Run(). EqualCode(xxx). Result(xxx). Equal(...). WriteFile(xxx). Err()
Index ¶
- Variables
- func CookieMapToSlice(cm map[string]string) []*http.Cookie
- func GinHandlerAPIDoc(doc *gin.RouterGroup, dir string, brand string)
- func JSONIndent(w io.Writer, v any)
- func MakeCatalog(entries []CatalogEntry) (string, error)
- func OpenFile(file, title string) (*os.File, error)
- func RegisterProxyMethod(pctx inject.ProxyContext, cf inject.CtxFunc)
- func RegisterTagName(tagName string)
- func XMLIndent(w io.Writer, v any)
- type APIError
- type AT
- func (at *AT) CatalogEntry() CatalogEntry
- func (at *AT) Debug() *AT
- func (at *AT) Equal(args ...any) *AT
- func (at *AT) EqualCode(wantCode int) *AT
- func (at *AT) EqualThen(f func(*AT) error, args ...any) *AT
- func (at *AT) Err() error
- func (at *AT) Errors(errs ...any) *AT
- func (at *AT) FakeRun() *AT
- func (at *AT) GetResultExtractor(format string) (re ResultExtractor, ok bool)
- func (at *AT) MarkAuthHeader(authHeaderKey, authHeaderValue string) *AT
- func (at *AT) Method() string
- func (at *AT) MonkeyRun() *AT
- func (at *AT) New() *AT
- func (at *AT) Path() string
- func (at *AT) PressureRun(n, c int) *AT
- func (at *AT) PressureRunBatch(param []PressureParam) *AT
- func (at *AT) RegisterResultExtractor(format string, re ResultExtractor) *AT
- func (at *AT) Resp() *http.Response
- func (at *AT) Result(r any) *AT
- func (at *AT) Run() *AT
- func (at *AT) SetCookies(cookies []*http.Cookie) *AT
- func (at *AT) SetFile(file string) *AT
- func (at *AT) SetHeader(header http.Header) *AT
- func (at *AT) SetHost(host string) *AT
- func (at *AT) SetParam(param any) *AT
- func (at *AT) SetPort(port string) *AT
- func (at *AT) SetScheme(scheme string) *AT
- func (at *AT) SetStatus(status Status) *AT
- func (at *AT) Title() string
- func (at *AT) UseXMLFormat() *AT
- func (at *AT) UseXMLParamFormat() *AT
- func (at *AT) UseXMLResultFormat() *AT
- func (at *AT) WriteFile(w io.Writer) *AT
- type ATMock
- func (mockRecv *ATMock) Debug() *AT
- func (mockRecv *ATMock) Equal(args ...any) *AT
- func (mockRecv *ATMock) EqualCode(wantCode int) *AT
- func (mockRecv *ATMock) EqualThen(f func(*AT) error, args ...any) *AT
- func (mockRecv *ATMock) Err() error
- func (mockRecv *ATMock) MonkeyRun() *AT
- func (mockRecv *ATMock) New() *AT
- func (mockRecv *ATMock) PressureRun(n int, c int) *AT
- func (mockRecv *ATMock) PressureRunBatch(param []PressureParam) *AT
- func (mockRecv *ATMock) Result(r any) *AT
- func (mockRecv *ATMock) Run() *AT
- func (mockRecv *ATMock) SetCookies(cookies []*http.Cookie) *AT
- func (mockRecv *ATMock) SetHeader(header http.Header) *AT
- func (mockRecv *ATMock) SetParam(param any) *AT
- func (mockRecv *ATMock) SetPort(port string) *AT
- func (mockRecv *ATMock) WriteFile(w io.Writer) *AT
- type CatalogEntry
- type IAT
- type Link
- type PressureParam
- type ResultExtractor
- type SimpleKind
- type Status
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ATMockDebugProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "Debug" return }() ATMockEqualProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "Equal" return }() ATMockEqualCodeProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "EqualCode" return }() ATMockEqualThenProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "EqualThen" return }() ATMockErrProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "Err" return }() ATMockMonkeyRunProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "MonkeyRun" return }() ATMockNewProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "New" return }() ATMockPressureRunProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "PressureRun" return }() ATMockPressureRunBatchProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "PressureRunBatch" return }() ATMockResultProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "Result" return }() ATMockRunProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "Run" return }() ATMockSetCookiesProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "SetCookies" return }() ATMockSetHeaderProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "SetHeader" return }() ATMockSetParamProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "SetParam" return }() ATMockSetPortProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "SetPort" return }() ATMockWriteFileProxyContext = func() (pctx inject.ProxyContext) { pctx = aTMockCommonProxyContext pctx.MethodName = "WriteFile" return }() )
View Source
var ( // ErrNilParam 参数为nil ErrNilParam = errors.New("please input param, param is nil now") )
Predefined error
Functions ¶
func CookieMapToSlice ¶
CookieMapToSlice map转为slice
func GinHandlerAPIDoc ¶ added in v0.13.0
func GinHandlerAPIDoc(doc *gin.RouterGroup, dir string, brand string)
GinHandlerAPIDoc 针对指定目录下的md接口文档,生成对应的html文件,并注册到gin路由上
func MakeCatalog ¶ added in v0.13.0
func MakeCatalog(entries []CatalogEntry) (string, error)
func RegisterProxyMethod ¶ added in v0.12.0
func RegisterProxyMethod(pctx inject.ProxyContext, cf inject.CtxFunc)
func RegisterTagName ¶ added in v0.13.1
func RegisterTagName(tagName string)
Types ¶
type AT ¶
type AT struct {
// contains filtered or unexported fields
}
AT api test
func (*AT) CatalogEntry ¶ added in v0.13.0
func (at *AT) CatalogEntry() CatalogEntry
func (*AT) GetResultExtractor ¶ added in v0.24.0
func (at *AT) GetResultExtractor(format string) (re ResultExtractor, ok bool)
func (*AT) MarkAuthHeader ¶ added in v0.8.2
func (*AT) PressureRunBatch ¶
func (at *AT) PressureRunBatch(param []PressureParam) *AT
PressureRunBatch 批量压力运行
func (*AT) RegisterResultExtractor ¶ added in v0.24.0
func (at *AT) RegisterResultExtractor(format string, re ResultExtractor) *AT
func (*AT) UseXMLFormat ¶ added in v0.13.0
UseXMLFormat 设置参数和结果格式为XML
func (*AT) UseXMLParamFormat ¶ added in v0.13.0
UseXMLParamFormat 设置参数格式为XML
func (*AT) UseXMLResultFormat ¶ added in v0.13.0
UseXMLResultFormat 设置结果格式为XML
type ATMock ¶ added in v0.5.0
type ATMock struct { DebugFunc func() *AT EqualFunc func(args ...any) *AT EqualCodeFunc func(wantCode int) *AT EqualThenFunc func(f func(*AT) error, args ...any) *AT ErrFunc func() error MonkeyRunFunc func() *AT NewFunc func() *AT PressureRunFunc func(n int, c int) *AT PressureRunBatchFunc func(param []PressureParam) *AT ResultFunc func(r any) *AT RunFunc func() *AT SetCookiesFunc func(cookies []*http.Cookie) *AT SetHeaderFunc func(header http.Header) *AT SetParamFunc func(param any) *AT SetPortFunc func(port string) *AT WriteFileFunc func(w io.Writer) *AT }
func (*ATMock) PressureRunBatch ¶ added in v0.5.0
func (mockRecv *ATMock) PressureRunBatch(param []PressureParam) *AT
func (*ATMock) SetCookies ¶ added in v0.5.0
type CatalogEntry ¶ added in v0.13.0
type IAT ¶ added in v0.5.0
type IAT interface { Debug() *AT Equal(args ...any) *AT EqualCode(wantCode int) *AT EqualThen(f func(*AT) error, args ...any) *AT Err() error MonkeyRun() *AT New() *AT PressureRun(n int, c int) *AT PressureRunBatch(param []PressureParam) *AT Result(r any) *AT Run() *AT SetCookies(cookies []*http.Cookie) *AT SetHeader(header http.Header) *AT SetParam(param any) *AT SetPort(port string) *AT WriteFile(w io.Writer) *AT }
type ResultExtractor ¶ added in v0.24.0
type SimpleKind ¶ added in v0.12.0
Source Files ¶
Click to show internal directories.
Click to hide internal directories.