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}) }, }, }