Skip to content

Instantly share code, notes, and snippets.

@niquola
Created September 5, 2019 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niquola/50f9c72ee3a913a94537387d4ba8d313 to your computer and use it in GitHub Desktop.
Save niquola/50f9c72ee3a913a94537387d4ba8d313 to your computer and use it in GitHub Desktop.

Test Cases for Aidbox

File simple-crud.yaml

desc: Simple CRUD tutorial                                                                                                                                                                                                                                                                                                            [0/1664]

steps:
- id: clean
  desc: Clear all patients
  request:
    method: POST
    uri: /$sql
    body: TRUNCATE PATIENT
  match:
    status: 201
    body:
      id: pt-1
- id: create
  desc: Create test patient
  request:
    method: POST
    uri: /Patient
    body:
      id: pt-1
      name: [{given: ['Vladislav']}]
  match:
    status: 201
    body:
      id: pt-1
- id: read
  desc: Read our patient
  request:
    uri: /Patient/pt-1
  match:
    status: 200
    body:
      id: pt-1
      name: [{given: ['Vladislav']}]
- id: search-by-id
  request:
    uri: /Patient?_id=pt-1
  match:
    status: 200
    body:
      entry:
      - resource: {resourceType: 'Patient', id: 'pt-1'}
- id: update
  desc: Now let's update our patient
  request:
    uri: /Patient/pt-1
    method: PUT
    body:
      name: [{given: ['Vlad'], family: 'Ganshin'}]
  match:
    status: 200
    body:
      name: [{family: 'Ganshin'}]

- id: wrong update
  desc: If structure is wrong - aidbox will report error and return status 422
  request:
    uri: /Patient/pt-1
    method: PUT
    body:
      name: [{given: ['Vlad'], family: 'Ganshin'}]
      ups: extra
  match:
    status: 422
    body:
      issue:
      - expression: '.ups'
- id: delete
  request:
    uri: /Patient/pt-1
    method: DELETE
  response:
    status: 200
- id: read-404
  request:
    uri: /Patient/pt-1
  match:
    status: 404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment