-
This unit test will create document with not existing index:
POST
call to the endpoint/es/notExistIndex/_doc
with indexData in body.- The indexData in json form defined in init.go file.
- 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 document is indexed.
-
This unit test will create document with exisiting index:
POST
call to the endpoint/es/"+indexName+"/_doc
with indexData 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 document is indexed.
-
This unit test will index document with existing Index and not existing ID:
POST
call to the endpoint/es/"+indexName+"/_doc
with indexData 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 document is indexed.
- Unmarshal the json recieved in the response body and will check if there is no error using assert.NoError and using assert.NotEqual to check that "id" is not an empty value.
- Storing the value of id recieved in the json response in a variable _id to be used in the next test.
-
This unit test will update document with existing Index and exisitng ID:
POST
call to the endpoint/es/"+indexName+"/_doc
with indexData in body.- Updating indexData by adding a field _id with the value that was stored in the last test using string.Replace.
- 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 document is updated with existing Document ID.
-
THis unit test will create document with error Input:
POST
call to the endpoint/es/"+indexName+"/_doc
withdata
in the 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.StatusBadRequest (i.e 400),that means test is OK.