Compare commits
2 Commits
v1.6.8
..
8fb6565d9f
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fb6565d9f | |||
| 3ff3953dff |
@@ -61,6 +61,32 @@ func (a *Api) WithSession(s Map) *Api {
|
||||
}
|
||||
}
|
||||
|
||||
// AtPath 返回指向其它 API 路径的 Api(跨接口断言时用)
|
||||
func (a *Api) AtPath(path string) *Api {
|
||||
return &Api{
|
||||
app: a.app,
|
||||
path: path,
|
||||
t: a.t,
|
||||
session: a.session,
|
||||
}
|
||||
}
|
||||
|
||||
// RunSub 在单个接口测试 Func 内再分子场景,便于 go test -run 收窄。
|
||||
func (a *Api) RunSub(desc string, fn func(a *Api)) {
|
||||
if a == nil || a.t == nil {
|
||||
fn(a)
|
||||
return
|
||||
}
|
||||
a.t.Run(desc, func(t *testing.T) {
|
||||
fn(&Api{
|
||||
app: a.app,
|
||||
path: a.path,
|
||||
t: t,
|
||||
session: a.session,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// JSON 设置 JSON body,返回 ApiCase 构建器
|
||||
func (a *Api) JSON(body interface{}) *ApiCase {
|
||||
c := a.newCase()
|
||||
|
||||
Reference in New Issue
Block a user