Skip to content

Commit

Permalink
Add body to PutMapping Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcook committed Oct 17, 2024
1 parent e9f3017 commit b2483dd
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions tests/endpoints/IndicesTest/PutMappingTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
local PutMapping = require "elasticsearch.endpoints.Indices.PutMapping"
local MockTransport = require "lib.MockTransport"
local getmetatable = getmetatable
local parser = require "elasticsearch.parser"

-- Setting up environment
local _ENV = lunit.TEST_CASE "tests.endpoints.IndicesTest.PutMappingTest"
Expand Down Expand Up @@ -32,9 +33,23 @@ function requestTest()
mockTransport.method = "PUT"
mockTransport.uri = "/_mapping"
mockTransport.params = {}
mockTransport.body = nil
mockTransport.body = parser.jsonEncode{
properties = {
email = {
type = "keyword"
}
}
}

endpoint:setParams{}
endpoint:setParams{
body = {
properties = {
email = {
type = "keyword"
}
}
}
}

local _, err = endpoint:request()
assert_not_nil(err)
Expand All @@ -45,10 +60,23 @@ function requestIndexTest()
mockTransport.method = "PUT"
mockTransport.uri = "/users/_mapping"
mockTransport.params = {}
mockTransport.body = nil
mockTransport.body = parser.jsonEncode{
properties = {
email = {
type = "keyword"
}
}
}

endpoint:setParams{
index = "users"
index = "users",
body = {
properties = {
email = {
type = "keyword"
}
}
}
}

local _, err = endpoint:request()
Expand Down

0 comments on commit b2483dd

Please sign in to comment.