Skip to content

Commit

Permalink
doc(api-test): add multi-stage demo for api-test 2.0 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfwn authored Jul 9, 2024
1 parent 769a89a commit afcc1e8
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions actions/api-test/2.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,41 @@

#### 使用

推荐通过图形化界面进行编辑。

通过声明出参,可以将接口返回的数据传递给下游 action,例如下例中的 `a-cookie`

```yaml
api-test:
version: 2.0
params:
name: 访问 Dice 官网
url: https://dice.terminus.io
method: GET
params:
- key: p1
value: v1
- key: p2
value: v2
headers:
- key: h1
value: v1
- key: h2
value: v2
body:
type: application/json
content: '{"name":"dice"}'
```
version: "1.1"
stages:
- stage:
- api-test:
description: 执行单个接口测试。上层可以通过 pipeline.yml 编排一组接口测试的执行顺序。
version: "2.0"
params:
asserts:
- arg: a-cookie
operator: not_empty
body:
type: none
method: GET
out_params:
- expression: Set-Cookie
key: a-cookie
source: header
url: https://www.erda.cloud/api/users/me
timeout: 3600
- stage:
- custom-script:
alias: cookie-printer
description: 运行自定义命令
version: "2.0"
commands:
- |-
c="${{ outputs.api-test.a-cookie }}"
echo "I got a cookie: $c"
- 'echo "action meta: b-cookie=$c"'
resources:
cpu: 0.1
mem: 256
```

0 comments on commit afcc1e8

Please sign in to comment.