File tree Expand file tree Collapse file tree 4 files changed +276
-203
lines changed
docs/site/content/zh/latest/tasks Expand file tree Collapse file tree 4 files changed +276
-203
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,12 @@ items:
12
12
{
13
13
"count": 1,
14
14
"items": [{
15
- "title": "fix: there is a bug on page {{ randEnum "one" }}",
15
+ "title": "fix: there is a bug on page {{ randEnum "one" "two" "three" "four" }}",
16
16
"number": {{randInt 100 199}},
17
17
"float": {{randFloat 0.0 1.0}},
18
+ "status": "{{randWeightEnum (weightObject 4 "open") (weightObject 1 "closed")}}",
18
19
"message": "{{.Response.Header.server}}",
19
- "author": "someone",
20
- "status": "success",
20
+ "author": "{{env "USER"}}",
21
21
"created": "{{ now.Format "2006-01-02T15:04:05Z07:00" }}"
22
22
}],
23
23
"uptime": "{{uptime}}"
Original file line number Diff line number Diff line change @@ -10,4 +10,28 @@ title = "用例模板"
10
10
11
11
```
12
12
182{{shuffle "09876543"}}
13
- ```
13
+ ```
14
+
15
+ ## 带权重的随机枚举
16
+
17
+ 下面的代码以 80% 的概率返回 ` open ` ,以 20% 的概率返回 ` closed ` :
18
+
19
+ ```
20
+ {{randWeightEnum (weightObject 4 "open") (weightObject 1 "closed")}}
21
+ ```
22
+
23
+ ## 时间
24
+
25
+ 下面的代码可以生成当前时间,并制定时间格式:
26
+
27
+ ```
28
+ {{ now.Format "2006-01-02T15:04:05Z07:00" }}
29
+ ```
30
+
31
+ ## 环境变量
32
+
33
+ 下面的代码可以获取环境变量 ` SHELL ` 的值,在需要使用一个全局变量的时候,可以使用这个模板函数:
34
+
35
+ ```
36
+ {{ env "SHELL" }}
37
+ ```
You can’t perform that action at this time.
0 commit comments