test

package
v0.0.0-...-ed2f012 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Env     = "57"  //test  57 local  71access
	Service = "ums" //ums os_center sc

)

Functions

func CheckFail

func CheckFail(t CanLog, err error)

func CheckResponseWriter

func CheckResponseWriter(maynil bool, wResp *httptest.ResponseRecorder, code int, msg string) (respObj g.Resp, err error)

func GetParams

func GetParams(body map[string]interface{}) (ps string)

GetParams 转成url参数格式

func JsonToFile

func JsonToFile(interfaces interface{}, fileName string)

func NewGinContext

func NewGinContext(method, url string, body []byte, header map[string]string, w *httptest.ResponseRecorder) (*gin.Context, error)

func NewGinContext2

func NewGinContext2(body interface{}, method, pathAndParam string) (c *gin.Context, w *httptest.ResponseRecorder, err error)

func NewGinContext3

func NewGinContext3(body string, method, pathAndParam string) (c *gin.Context, w *httptest.ResponseRecorder, err error)

func NextLogID

func NextLogID() string

Types

type CanLog

type CanLog interface {
	Errorf(format string, args ...interface{})
	Error(args ...interface{})
	Logf(format string, args ...interface{})
	Log(args ...interface{})
	Fatalf(format string, args ...interface{})
	Fatal(args ...interface{})
}

type Case

type Case struct {
	T         *testing.T
	JSONDatas []string
	Contexs   []map[string]interface{}                                 //中间结果
	Init      func(str string, ctx map[string]interface{}) (ok bool)   //初始化函数
	Tests     []func(str string, ctx map[string]interface{}) (ok bool) //测试函数
	Clean     func(ctx map[string]interface{}) (ok bool)               //清理函数
}

测试用例

func (*Case) Add

func (p *Case) Add(datas ...string) (ok bool)

func (*Case) Do

func (p *Case) Do(t *testing.T) (ok bool)

type Resp

type Resp struct {
	Code int                    `json:"code"`
	Msg  string                 `json:"msg"`
	Data map[string]interface{} `json:"data,omitempty"`
}

func HTTPDo

func HTTPDo(url, path, method string, body map[string]interface{}, t CanLog) (objBody Resp, err error)

func HTTPDoWithAuth

func HTTPDoWithAuth(header map[string]string, url, path, method, body, username, password string, checkErr bool, t CanLog) (objBody Resp, err error)

func HTTPDoWithCheckErr

func HTTPDoWithCheckErr(header map[string]string, url, path, method, body string, checkErr bool, t CanLog) (objBody Resp, err error)

func HTTPDoWithHeader

func HTTPDoWithHeader(header map[string]string, url, path, method, body string, t CanLog) (objBody Resp, err error)

Jump to

Keyboard shortcuts

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