packages feed

curl-runnings-0.9.2: examples/interpolation-spec.yaml

---
# use the !include <file> yaml directive for import data from other yaml files!
include: !include ./importable.yaml
cases:
  - name: test 1 
    # interpolate environment variables with ${...} just like you would in bash
    url: 'https://tabdextension.com/${ping_path}'
    headers: 'ping: ${ping_path}'
    requestMethod: GET
    expectData:
      exactly:
        ping: pong
    expectStatus: 200

  - name: test should pass
    url: https://tabdextension.com/ping
    requestMethod: GET
    expectData:
      exactly:
        # a string can be interpolated with variables inside of a $<...>
        # a query should start by indexing the array `RESPONSES` which contains
        # the json results of all previous test results. otherwise, use normal json / jq syntax.
        # you can put just a bare query and subsitute any json value, or use several queries
        # combined with raw text and substitue string values
        # NOTE - The legacy reserved variable SUITE is still supported at this time, but may not
        # be in a future version of curl-runnings.
        ping: $<RESPONSES[0].ping>
    expectStatus: 200

  - name: test will fail
    url: https://tabdextension.com/ping
    requestMethod: GET
    expectHeaders: "ping: $<RESPONSES[-1].ping>; ${ping_path}: pong"
    expectStatus: 200

  - name: test will fail
    url: https://tabdextension.com/ping
    requestMethod: GET
    expectData:
      contains:
        - keyValueMatch:
            # environment interpolation just like bash
            key: 'interpolated ${env_variable} ${another_variable}-key'
            value: ${ping_value}
        - keyValueMatch:
            key: msg
            value: $<RESPONSES[0].msg>
        # here, we are interpolating several string values into a string
        - valueMatch: 'hello $<RESPONSES[0].ping> : $<RESPONSES[0].ping> trailing text'
        - valueMatch: $<RESPONSES[0].okay>
    expectStatus: 200

  - name: test should pass
    url: https://tabdextension.com/ping
    requestMethod: GET
    expectData:
      notContains:
        - keyValueMatch:
            # environment interpolation just like bash
            key: 'interpolated ${env_variable} ${another_variable}-key'
            value: ${ping_value}
        - keyValueMatch:
            key: msg
            value: $<RESPONSES[0].msg>
        # here, we are interpolating several string values into a string
        - valueMatch: 'hello $<RESPONSES[0].ping> : $<RESPONSES[0].ping> trailing text'
        - valueMatch: $<RESPONSES[0].okay>
        # use anchors from this file or an imported one. here, `ping` is an anchor defined in importable.yaml
        - valueMatch: *ping
    expectStatus: 200