Skip to content

CICD-084 · Check a local API health contract ​

Encyclopedia · Tests and quality checks · All snippets

Previous · CICD-083 · Next · CICD-085

1. Where it fits ​

  • Placement Bash run step following checkout, or equivalent lab terminal.
  • Prerequisites repository with test fixtures and task-specific quality dependencies.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
curl -fsS http://127.0.0.1:8000/healthz | jq -e '.status=="ok"'

3. How it works ​

The request checks the selected HTTP interface. Timeouts limit waiting, and an explicit exit or payload condition determines pass and fail. The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate.

4. Verify the result ​

Start the service and wait for readiness before the assertion.

Validation syntax-validated (Bash parse). Status definitions.