packages feed

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

---
# A curl runnings spec is an object with an array of `cases`.
# Note: the legacy format of a top level array of cases is still supported at this time, but it's recommended
# to migrate to the new format, as it may not be supported in later versions.
cases:
  - name: test 1 # required
    url: http://your-endpoint.com/status # required
    requestMethod: GET # required
    # [Optional] Specify the json payload we expect here
    # The 1 key in this block should be either:
    # exactly | contains
    expectData:
      # The 1 key in this object specifies the matcher we want
      # to use to test the returned payload. In this case, we
      # require the payload is exactly what we specify.
      exactly:
        okay: true
        msg: 'a message'
    # [Required] Assertions about the returned status code. Pass in
    # an acceptable code or list of codes
    expectStatus: 200

  - name: test 2
    url: http://your-endpoint.com/path
    requestMethod: POST
    expectStatus:
    - 200
    - 201
    # [Optional] json data to send with the request
    requestData:
      hello: there
      num: 1

  - name: test 3
    url: http://your-url.com/other/path
    requestMethod: GET
    expectData:
      # In the `contains` case of data validation, a list of matchers is specified. Currently,
      # possible types are `keyMatch` | `valueMatch` | `keyValueMatch`.
      contains:
      # `keyValueMatch` looks for the key/value pair anywhere in the payload
      # here, {'okay': true} must be somewhere in the return payload
      - keyValueMatch:
          key: okay
          value: true
      # `valueMatch` searches for a value anywhere in the payload (note: _not_ a key).
      # Here, we look for the value `true` anywhere in the payload.
      # This can be useful for matching against values where you don't know the key ahead of time,
      # or for values in a top level array.
      - valueMatch: true
      # `keyMatch` searches for a key anywhere in the payload
      - keyMatch: okay
    expectStatus: 200

  - name: test 4
    url: http://your-url.com/other/path
    requestMethod: GET
    expectData:
      # In the `notContains` case of data validation, a list of matchers is specified. If any
      # matcher is found in the response payload, the test will fail. Currently,
      # possible matchers are `valueMatch` | `keyValueMatch`.
      notContains:
      - keyValueMatch:
          key: okay
          value: true
      - valueMatch: true
      # notContains + keyMatch works great for asserting no errors came back
      - keyMatch: error
    expectStatus: 200

  - name: test 5
    url: http://your-url.com/other/path
    requestMethod: GET
    expectData:
      # you can have both a contains and a notContains block in your expectData
      contains:
      - keyValueMatch:
          key: okay
          value: true
      notContains:
      - valueMatch: false
    expectStatus: 200

  - name: test 6
    url: http://your-url.com/other/path
    requestMethod: GET
    # Specify the headers you want to sent, just like the -H flag in a curl command
    # IE "key: value; key: value; ..."
    headers: "Content-Type: application/json"
    expectStatus: 200
    # The response must contain at least these headers exactly.
    # Header strings again match the -H syntax from curl
    expectHeaders: "Content-Type: application/json; Hello: world"

  - name: test 7
    url: http://your-url.com/other/path
    requestMethod: GET
    headers: "Content-Type: application/json"
    expectStatus: 200
    # You can also specify a key and/or value to look for in the headers
    expectHeaders: 
    -
      key: "Key-With-Val-We-Dont-Care-About"

  - name: test 8
    url: http://your-url.com/other/path
    requestMethod: GET
    headers: "Content-Type: application/json"
    expectStatus: 200
    # Specify a mix of full or partial header matches in a list like so:
    expectHeaders: 
    - "Hello: world"
    -
      value: "Value-With-Key-We-Dont-Care-About"