add: test timestamp extraction

Change-Id: I4aba2b7d387d8cb7b9c1baec997e59b1b594c34d
This commit is contained in:
buyuxiang
2022-02-20 14:00:27 +08:00
parent 50c4384207
commit 2ba1d5829e

View File

@@ -48,11 +48,18 @@ var demoTestCase = &hrp.TestCase{
WithBody(map[string]interface{}{
"foo1": "$varFoo1", // reference former extracted variable
"foo2": "${max($a, $b)}", // 12.3; step level variables are independent, variable b is 3.45 here
"time": "${get_timestamp()}",
}).
Extract().
WithJmesPath("body.form.time", "varTime").
Validate().
AssertEqual("status_code", 200, "check status code").
AssertLengthEqual("body.form.foo1", 5, "check args foo1").
AssertEqual("body.form.foo2", "12.3", "check args foo2"), // form data will be converted to string
hrp.NewStep("get with timestamp").
GET("/get").WithParams(map[string]interface{}{"time": "$varTime"}).
Validate().
AssertLengthEqual("body.args.time", 13, "check extracted var timestamp"),
},
}