apitest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2020 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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