-
This unit test will update mappings for Index:
PUT
call to the endpoint/api/"+indexName+"-mapping/_mapping
with{"properties":{"Athlete": {"type": "keyword"}}}
in body.- Send the request to 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.
- Using assert.Contains to test if the response body contains a string
"message":"ok"
, that means test is OK.
-
This unit test will GET mapping from Index:
GET
call to the endpoint/api/"+indexName+"/_mapping
.- Send the request to 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.
- Unmarshal the json response and using assert.NoError to check there is no error and using assert.NotNil to check if the data[indexName] is not nil.
- Creating map from data[indexName] and using assert.NotNil to check if the v["mappings] is not nil, that means the test is OK.