Skip to content

Commit

Permalink
Added tests for _doc.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Jun 10, 2024
1 parent e0bebb3 commit e4de666
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed

- Fixed GitHub pages ([#215](https://github.com/opensearch-project/opensearch-api-specification/pull/215))
- Fixed missing 201 response in `/{index}/_doc/{id}` ([#331](https://github.com/opensearch-project/opensearch-api-specification/pull/331))

### Security

Expand Down
2 changes: 1 addition & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ To assure the correctness of the spec, you must add tests for the spec in the [t
- chapters: These are the operations that are being tested.
- epilogues: These are the operations that are executed after the test story is run. They are used to clean up the environment after the test story.

Below is the simplified version of the test story that tests the [index operations](tests/index.yaml):
Below is the simplified version of the test story that tests the [index operations](tests/_core/index.yaml):
```yaml
$schema: ../json_schemas/test_story.schema.yaml # The schema of the test story. Include this line so that your editor can validate the test story on the fly.
Expand Down
12 changes: 12 additions & 0 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,8 @@ paths:
requestBody:
$ref: '#/components/requestBodies/index'
responses:
'201':
$ref: '#/components/responses/index@201'
'200':
$ref: '#/components/responses/index@200'
/{index}/_doc/{id}:
Expand Down Expand Up @@ -1291,6 +1293,8 @@ paths:
requestBody:
$ref: '#/components/requestBodies/index'
responses:
'201':
$ref: '#/components/responses/index@201'
'200':
$ref: '#/components/responses/index@200'
put:
Expand All @@ -1317,6 +1321,8 @@ paths:
requestBody:
$ref: '#/components/requestBodies/index'
responses:
'201':
$ref: '#/components/responses/index@201'
'200':
$ref: '#/components/responses/index@200'
delete:
Expand Down Expand Up @@ -2875,6 +2881,12 @@ components:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
index@201:
description: ''
content:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
info@200:
description: ''
content:
Expand Down
49 changes: 49 additions & 0 deletions tests/_core/index/_doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
$schema: ../../../json_schemas/test_story.schema.yaml

skip: false
description: Test inserting and retrieving a doc.
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Create a document.
path: /{index}/_doc/{id}
method: POST
parameters:
index: movies
id: '1'
request_body:
payload:
title: Beauty and the Beast
year: 1991
response:
status: 201
- synopsis: Update a document.
path: /{index}/_doc/{id}
method: PUT
parameters:
index: movies
id: '1'
request_body:
payload:
title: Beauty and the Beast (Updated)
year: 1991
response:
status: 200
- synopsis: Retrieve a document.
path: /{index}/_doc/{id}
method: GET
parameters:
index: movies
id: '1'
response:
status: 200
- synopsis: Delete a document.
path: /{index}/_doc/{id}
method: DELETE
parameters:
index: movies
id: '1'
response:
status: 200

0 comments on commit e4de666

Please sign in to comment.