feat(testing): Flows/FromCase、增量 swagger 与 Doc-Driven 门禁
补齐多接口流程联调与控制台体验,并落地仓内 Doc-Driven+TDD 总规则与文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
// DemoFlows 多接口业务流程联调示例(整条 Flow 共用一次测试事务,结束回滚)
|
||||
var DemoFlows = FlowTest{
|
||||
"expect_chain": {
|
||||
Group: "expect_demo",
|
||||
Desc: "expect_demo 多接口联调",
|
||||
Prep: "依次调用 string_result 与 map_result。\n步骤通过 FromCase 复用单接口验收用例的请求模板,跑通后回写该用例的响应与通过状态。",
|
||||
Func: func(f *Flow) {
|
||||
f.Step("字符串结果", "/app/expect_demo/string_result").
|
||||
FromCase("result是字符串").
|
||||
Note("校验字符串 result:期望返回「操作成功」。").
|
||||
Verify(func(a *Api) error {
|
||||
if a.Resp().GetBody().GetString("result") != "操作成功" {
|
||||
return fmt.Errorf("result 期望 操作成功")
|
||||
}
|
||||
return nil
|
||||
}).
|
||||
Get("步骤1-字符串", 0, "样本")
|
||||
|
||||
f.Step("Map结果", "/app/expect_demo/map_result").
|
||||
FromCase("result是Map-校验字段名+类型+值").
|
||||
Note("校验对象 result:至少包含 id=1,用于串联后续步骤前的结构确认。").
|
||||
Verify(func(a *Api) error {
|
||||
result := a.Resp().GetBody().GetMap("result")
|
||||
if result == nil {
|
||||
return fmt.Errorf("result 为 nil")
|
||||
}
|
||||
if result.GetCeilInt64("id") != 1 {
|
||||
return fmt.Errorf("id 期望 1")
|
||||
}
|
||||
return nil
|
||||
}).
|
||||
Get("步骤2-Map", 0, Map{"id": int64(1), "name": "sample", "price": float64(1.0), "in_stock": true})
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user