Skip to content

Commit

Permalink
Added a /{index}/_doc/{id} > DELETE > 200 > application/json test.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed May 13, 2024
1 parent e1799d1 commit 0f69f7e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
16 changes: 16 additions & 0 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,7 @@ paths:
operationId: delete.0
x-operation-group: delete
x-version-added: '1.0'
x-tested: true
description: Removes a document from the index.
externalDocs:
url: https://opensearch.org/docs/latest/api-reference/document-apis/delete-document/
Expand Down Expand Up @@ -2679,6 +2680,19 @@ components:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
examples:
application/json:
value:
_index: my-index
_id: "R5Umc48BxVNStfTNiYzC"
_version: 1
result: "deleted"
_shards:
total: 2
successful: 1
failed: 0
_seq_no: 0
_primary_term: 1
delete_all_pits@200:
description: ''
content:
Expand Down Expand Up @@ -3618,6 +3632,7 @@ components:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/Id'
style: simple
example: R5Umc48BxVNStfTNiYzC
delete::path.index:
in: path
name: index
Expand All @@ -3626,6 +3641,7 @@ components:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/IndexName'
style: simple
example: my-index
delete::query.if_primary_term:
in: query
name: if_primary_term
Expand Down
19 changes: 0 additions & 19 deletions spec/namespaces/cat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1465,25 +1465,6 @@ components:
type: boolean
default: false
description: Verbose mode. Display column headers.
cat.help::query.help:
name: help
in: query
description: Return help information.
schema:
type: boolean
default: false
description: Return help information.
cat.help::query.s:
name: s
in: query
description: Comma-separated list of column names or column aliases to sort by.
style: form
schema:
type: array
items:
type: string
description: Comma-separated list of column names or column aliases to sort by.
explode: true
cat.indices::path.index:
in: path
name: index
Expand Down
27 changes: 27 additions & 0 deletions tests/{index}/_doc/delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const hooks = require('hooks')
const fetch = require('node-fetch')

hooks.before('/{index}/_doc/{id} > DELETE > 200 > application/json', function (transaction, done) {
// create a document and update transaction URL for the document to be deleted
fetch(
`https://${transaction.host}:${transaction.port}/my-index/_doc`, {
method: 'POST',
headers: {
Authorization: transaction.request.headers.Authorization,
'Content-type': 'application/json'
},
body: JSON.stringify({
_x: '1'
})
})
.then((response) => {
response.json().then((body) => {
transaction.fullPath = `/my-index/_doc/${body._id}`
done()
})
})
.catch((error) => {
transaction.fail = error
done()
})
})
2 changes: 1 addition & 1 deletion tests/my-index/_doc/post.js → tests/{index}/_doc/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const hooks = require('hooks')
const fetch = require('node-fetch')

hooks.after('/{index}/_doc > POST > 201 > application/json', function (transaction, done) {
// delete newly created document
// cleanup, delete newly created document
fetch(
`https://${transaction.host}:${transaction.port}${transaction.real.headers.location}`, {
method: 'DELETE',
Expand Down

0 comments on commit 0f69f7e

Please sign in to comment.