apitest

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package apitest Usage:

NewAT(xxx).
	SetParam(xxx).
	Debug().
	Run().
	EqualCode(xxx).
	Result(xxx).
	Equal(...).
	WriteFile(xxx).
	Err()

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilParam 参数为nil
	ErrNilParam = errors.New("Please input param, param is nil now")
)

Predefined error

Functions

func CookieMapToSlice

func CookieMapToSlice(cm map[string]string) []*http.Cookie

CookieMapToSlice map转为slice

func JSONIndent

func JSONIndent(w io.Writer, v interface{})

JSONIndent json格式化后输出

func OpenFile

func OpenFile(file, title string) (*os.File, error)

OpenFile 打开文件

Types

type AT

type AT struct {
	// contains filtered or unexported fields
}

AT api test

func NewAT

func NewAT(
	path,
	method,
	comment string,
	h http.Header,
	cookies []*http.Cookie,
) *AT

NewAT 新建

func (*AT) Debug

func (at *AT) Debug() *AT

Debug 开启调试模式

func (*AT) Equal

func (at *AT) Equal(args ...interface{}) *AT

Equal 校验

func (*AT) EqualCode

func (at *AT) EqualCode(wantCode int) *AT

EqualCode 比较响应码

func (*AT) EqualThen

func (at *AT) EqualThen(f func(*AT) error, args ...interface{}) *AT

EqualThen 相等之后

func (*AT) Err

func (at *AT) Err() error

Err 获取error

func (*AT) MonkeyRun

func (at *AT) MonkeyRun() *AT

MonkeyRun 猴子运行

func (*AT) New

func (at *AT) New() *AT

New 克隆一个新的AT

func (*AT) PressureRun

func (at *AT) PressureRun(n, c int) *AT

PressureRun 压力运行,n: 运行次数,c: 并发数

func (*AT) PressureRunBatch

func (at *AT) PressureRunBatch(param []PressureParam) *AT

PressureRunBatch 批量压力运行

func (*AT) Result

func (at *AT) Result(r interface{}) *AT

Result 获取结果

func (*AT) Run

func (at *AT) Run() *AT

Run 运行

func (*AT) SetCookies

func (at *AT) SetCookies(cookies []*http.Cookie) *AT

SetCookies 设置cookies

func (*AT) SetHeader

func (at *AT) SetHeader(header http.Header) *AT

SetHeader 设置header

func (*AT) SetParam

func (at *AT) SetParam(param interface{}) *AT

SetParam 设置参数

func (*AT) SetPort

func (at *AT) SetPort(port string) *AT

SetPort 设置端口,如":8080"

func (*AT) WriteFile

func (at *AT) WriteFile(w io.Writer) *AT

WriteFile 写入文件

type PressureParam

type PressureParam struct {
	N int // 运行次数
	C int // 并发数
}

PressureParam 压力测试参数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL