-
This unit test will create document with not existing Index:
POST
call to the endpoint/es/notExistIndex/_bulk
with bulkData in body.- The bulkData in ndjson form defined in init.go file.
- Using Replaceall to replace bulkData
_index
value with an empty string. - Send a request to the server and response would be recorded.
- Using assert.Equal will test if the response code is equal to http.StatusOK (i.e 200),that means test is OK and bulk document is indexed with Index notExistIndex.
-
This unit test will create document with existing Index:
- Create Index request to check that Index already exists by
PUT
call to the endpoint/api/index
with{"name": "
+ indexName +", "storage_type": "disk"}
in body. - Using assert.Equal will test if the response code is equal to http.StatusBadRequest (i.e 400), that means Index already exists.
- Umarshal the response recieved and using assert.Equal will check that error string is equal to index
["+indexName+"] already exists
. POST
call to the endpoint/es/"+indexName+"/_bulk
with bulkData in body.- Send a request to the server and response would be recorded.
- Using assert.Equal will test if the response code is equal to http.StatusOK (i.e 200),that means test is OK and bulk document is indexed.
- Create Index request to check that Index already exists by
-
This unit test will index documents with error input:
POST
call to the endpoint/es/"+indexName+"/_bulk
with{"index": {}}
in body .- Send a request to the server and response would be recorded.
- Using assert.Equal will test if the response code is equal to http.StatusOK (i.e 200),that means test is OK.