zrizDocsLearnSecuritySign inSign up

Write your first zriz test

Add one HTTP call of your own service to the project, write one pipeline with one check, and run it. The work is done when the run has status pass.

Draft. Guide · zz 0.4.0 or later · Updated · Plain text for agents: /docs/first-test.md

The sample hello showed that the project works. This test is your own: one pipeline that calls one path of your service.

The page Pipelines gives the full format. zz guide prints the same text.

Before you start

1. Add the call to the resource

Do

Open .zriz/resources/target.json. zz init wrote it. Add one action to actions, and keep the action check as it is.

.zriz/resources/target.json:

{
  "type": "http",
  "description": "Your app under test",
  "base-url": "${env.TARGET_URL}",
  "actions": {
    "check": { "method": "GET", "path": "<health path>" },
    "<action>": { "method": "GET", "path": "<path>" }
  }
}
zz validate hello

Why

A step can call only an action that a resource file names. The base URL comes from TARGET_URL in .zriz/environments/local.json.

You should see

{"ok":true,"command":"validate",

If not

2. Write the pipeline

Do

Make a new file in .zriz/pipelines. The name of the file is the name of the pipeline.

.zriz/pipelines/<pipeline>.json:

{
  "description": "<description>",
  "steps": [
    { "call": "target/<action>", "expect": [["status", "==", 200]] }
  ]
}
zz validate <pipeline>

Why

The pipeline has one step and one check. The check passes when your service answers status 200.

You should see

{"ok":true,"command":"validate",

If not

3. Run the test

Do

Start your service. <pipeline> is the name from step 2.

zz run <pipeline>

Why

zz validate checks the files only. A run makes the call and does the check.

You should see

"status":"pass"

If not

Next