defaults:
  request_headers:
    X-Auth-Token: $ENVIRON['OS_TOKEN']

tests:
- name: environment with parameter
  POST: /stacks
  request_headers:
    content-type: application/json
  data:
    files: {}
    disable_rollback: true
    parameters: {}
    stack_name: $ENVIRON['PREFIX']-envstack
    environment:
      parameters:
        test_val: test
    template:
      heat_template_version: '2016-04-08'
      parameters:
        test_val:
          type: string
      resources:
        test:
          type: OS::Heat::TestResource
          properties:
            value: {get_param: test_val}
      outputs:
        output_value:
          value: {get_attr: [test, output]}

  status: 201
  response_headers:
    location: //stacks/$ENVIRON['PREFIX']-envstack/[a-f0-9-]+/

- name: poll for envstack CREATE_COMPLETE
  GET: $LOCATION
  redirects: True
  poll:
    count: 5
    delay: 1.0
  response_json_paths:
    $.stack.stack_status: CREATE_COMPLETE

- name: get stack output
  GET: $LAST_URL/outputs/output_value
  redirects: True
  status: 200
  response_json_paths:
    $.output.output_value: test

- name: delete envstack
  DELETE: /stacks/$ENVIRON['PREFIX']-envstack
  redirects: True
  status: 204
