From 86c497943044b6ae5ee5a5e5cd472c20957ad1fa Mon Sep 17 00:00:00 2001 From: Neil Cook Date: Thu, 17 Oct 2024 16:02:16 +0100 Subject: [PATCH] Clean redundant type code and remove deprecated/non-existent APIs such as Warmer --- src/elasticsearch/Indices.lua | 110 ----------------- src/elasticsearch/endpoints/Bulk.lua | 8 +- .../endpoints/Indices/DeleteMapping.lua | 5 +- .../endpoints/Indices/DeleteWarmer.lua | 55 --------- .../endpoints/Indices/ExistsType.lua | 58 --------- .../endpoints/Indices/GetFieldMapping.lua | 3 - .../endpoints/Indices/GetMapping.lua | 5 +- .../endpoints/Indices/GetWarmer.lua | 64 ---------- .../endpoints/Indices/IndicesEndpoint.lua | 3 - .../endpoints/Indices/PutMapping.lua | 6 +- .../endpoints/Indices/PutWarmer.lua | 62 ---------- .../endpoints/Indices/ValidateQuery.lua | 3 - .../IndicesTest/DeleteWarmerTest.lua | 65 ---------- .../endpoints/IndicesTest/ExistsTypeTest.lua | 66 ---------- tests/endpoints/IndicesTest/GetWarmerTest.lua | 116 ------------------ tests/endpoints/IndicesTest/PutWarmerTest.lua | 107 ---------------- tests/endpoints/IndicesTest/init.lua | 4 - 17 files changed, 6 insertions(+), 734 deletions(-) delete mode 100644 src/elasticsearch/endpoints/Indices/DeleteWarmer.lua delete mode 100644 src/elasticsearch/endpoints/Indices/ExistsType.lua delete mode 100644 src/elasticsearch/endpoints/Indices/GetWarmer.lua delete mode 100644 src/elasticsearch/endpoints/Indices/PutWarmer.lua delete mode 100644 tests/endpoints/IndicesTest/DeleteWarmerTest.lua delete mode 100644 tests/endpoints/IndicesTest/ExistsTypeTest.lua delete mode 100644 tests/endpoints/IndicesTest/GetWarmerTest.lua delete mode 100644 tests/endpoints/IndicesTest/PutWarmerTest.lua diff --git a/src/elasticsearch/Indices.lua b/src/elasticsearch/Indices.lua index 7bdd8f7..d367c7e 100644 --- a/src/elasticsearch/Indices.lua +++ b/src/elasticsearch/Indices.lua @@ -429,40 +429,6 @@ function Indices:putTemplate(params) return self:requestEndpoint("PutTemplate", params) end -------------------------------------------------------------------------------- --- Exists Type function --- --- @usage --- params["index"] = (list) A comma-separated list of index names; use '_all' to check the types --- across all indices (Required) --- ["type"] = (list) A comma-separated list of document types to check (Required) --- ["ignore_unavailable"] = (boolean) Whether specified concrete indices should be ignored when unavailable --- (missing or closed) --- ["allow_no_indices"] = (boolean) Whether to ignore if a wildcard indices expression resolves into no --- concrete indices. (This includes '_all' string or when no indices have been specified) --- ["expand_wildcards"] = (enum) Whether to expand wildcard expression to concrete indices that are open, --- closed or both. (open,closed,none,all) (default: open) --- ["local"] = (boolean) Return local information, do not retrieve the state from master node --- (default: false) --- --- @param params The put template Parameters --- --- @return table Error or the data received from the elasticsearch server -------------------------------------------------------------------------------- -function Indices:existsType(params) - local temp, err = self:requestEndpoint("ExistsType", params) - if err == 200 then - -- Successfull request - return true - elseif err:match("Invalid response code") then - -- Wrong response code - return false - else - -- Some other error, notify user - return nil, err - end -end - ------------------------------------------------------------------------------- -- Get Upgrade function -- @@ -556,82 +522,6 @@ function Indices:validateQuery(params) return self:requestEndpoint("ValidateQuery", params) end -------------------------------------------------------------------------------- --- Delete Warmer function --- --- @usage --- params["index"] = (list) A comma-separated list of index names to delete warmers from (supports --- wildcards); use '_all' to perform the operation on all indices. (Required) --- ["name"] = (list) A comma-separated list of warmer names to delete (supports wildcards); use --- '_all' to delete all warmers in the specified indices. You must specify a name either in the uri or in the --- parameters. --- ["master_timeout"] = (time) Specify timeout for connection to master --- --- @param params The delete warmer Parameters --- --- @return table Error or the data received from the elasticsearch server -------------------------------------------------------------------------------- -function Indices:deleteWarmer(params) - return self:requestEndpoint("DeleteWarmer", params) -end - -------------------------------------------------------------------------------- --- Get Warmer function --- --- @usage --- params["index"] = (list) A comma-separated list of index names to restrict the operation; use --- '_all' to perform the operation on all indices --- ["name"] = (list) The name of the warmer (supports wildcards); leave empty to get all --- warmers --- ["type"] = (list) A comma-separated list of document types to restrict the operation; leave --- empty to perform the operation on all types --- ["ignore_unavailable"] = (boolean) Whether specified concrete indices should be ignored when unavailable --- (missing or closed) --- ["allow_no_indices"] = (boolean) Whether to ignore if a wildcard indices expression resolves into no --- concrete indices. (This includes '_all' string or when no indices have been specified) --- ["expand_wildcards"] = (enum) Whether to expand wildcard expression to concrete indices that are open, --- closed or both. (open,closed,none,all) (default: open) --- ["local"] = (boolean) Return local information, do not retrieve the state from master node --- (default: false) --- --- @param params The get warmer Parameters --- --- @return table Error or the data received from the elasticsearch server -------------------------------------------------------------------------------- -function Indices:getWarmer(params) - return self:requestEndpoint("GetWarmer", params) -end - -------------------------------------------------------------------------------- --- Put Warmer function --- --- @usage --- params["index"] = (list) A comma-separated list of index names to register the warmer for; use --- '_all' or omit to perform the operation on all indices --- ["name"] = (string) The name of the warmer (Required) --- ["type"] = (list) A comma-separated list of document types to register the warmer for; --- leave empty to perform the operation on all types --- ["master_timeout"] = (time) Specify timeout for connection to master --- ["ignore_unavailable"] = (boolean) Whether specified concrete indices should be ignored when unavailable --- (missing or closed) in the search request to warm --- ["allow_no_indices"] = (boolean) Whether to ignore if a wildcard indices expression resolves into no --- concrete indices in the search request to warm. (This includes '_all' string or when no indices have been --- specified) --- ["expand_wildcards"] = (enum) Whether to expand wildcard expression to concrete indices that are open, --- closed or both, in the search request to warm. (open,closed,none,all) (default: open) --- ["request_cache"] = (boolean) Specify whether the request to be warmed should use the request cache, --- defaults to index level setting --- ["body"] = The search request definition for the warmer (query, filters, facets, sorting, --- etc) --- --- @param params The put warmer Parameters --- --- @return table Error or the data received from the elasticsearch server -------------------------------------------------------------------------------- -function Indices:putWarmer(params) - return self:requestEndpoint("PutWarmer", params) -end - ------------------------------------------------------------------------------- -- Function to check whether an index exists or not -- diff --git a/src/elasticsearch/endpoints/Bulk.lua b/src/elasticsearch/endpoints/Bulk.lua index 9b5deb4..0339216 100644 --- a/src/elasticsearch/endpoints/Bulk.lua +++ b/src/elasticsearch/endpoints/Bulk.lua @@ -40,12 +40,10 @@ end ------------------------------------------------------------------------------- function Bulk:getUri() local uri = "/_bulk" - if self.index ~= nil and self.type ~= nil then - uri = "/" .. self.index .. "/" .. self.type .. uri - elseif self.index ~= nil then + if self.index ~= nil then uri = "/" .. self.index .. uri - elseif self.type ~= nil then - uri = "/_all/" .. self.type .. uri + else + uri = "/_all" .. uri end return uri end diff --git a/src/elasticsearch/endpoints/Indices/DeleteMapping.lua b/src/elasticsearch/endpoints/Indices/DeleteMapping.lua index 0126aba..e1a10e0 100644 --- a/src/elasticsearch/endpoints/Indices/DeleteMapping.lua +++ b/src/elasticsearch/endpoints/Indices/DeleteMapping.lua @@ -35,10 +35,7 @@ function DeleteMapping:getUri() if self.index == nil then return nil, "index not specified for Delete Mapping" end - if self.type == nil then - return nil, "type not specified for Delete Mapping" - end - return "/" .. self.index .. "/" .. self.type .. "/_mapping" + return "/" .. self.index .. "/_mapping" end ------------------------------------------------------------------------------- diff --git a/src/elasticsearch/endpoints/Indices/DeleteWarmer.lua b/src/elasticsearch/endpoints/Indices/DeleteWarmer.lua deleted file mode 100644 index 1ef530d..0000000 --- a/src/elasticsearch/endpoints/Indices/DeleteWarmer.lua +++ /dev/null @@ -1,55 +0,0 @@ -------------------------------------------------------------------------------- --- Importing modules -------------------------------------------------------------------------------- -local IndicesEndpoint = require "elasticsearch.endpoints.Indices.IndicesEndpoint" - -------------------------------------------------------------------------------- --- Declaring module -------------------------------------------------------------------------------- -local DeleteWarmer = IndicesEndpoint:new() - -------------------------------------------------------------------------------- --- Declaring Instance variables -------------------------------------------------------------------------------- - --- The parameters that are allowed to be used in params -DeleteWarmer.allowedParams = { - ["name"] = true, - ["master_timeout"] = true -} - -------------------------------------------------------------------------------- --- Function to calculate the http request method --- --- @return string The HTTP request method -------------------------------------------------------------------------------- -function DeleteWarmer:getMethod() - return "DELETE" -end - -------------------------------------------------------------------------------- --- Function to calculate the URI --- --- @return string The URI -------------------------------------------------------------------------------- -function DeleteWarmer:getUri() - if self.index == nil then - return nil, "index not specified for Delete Warmer" - elseif self.name == nil then - return nil, "name not specified for Delete Warmer" - end - local uri = "/" .. self.index .. "/_warmer/" .. self.name - return uri -end - -------------------------------------------------------------------------------- --- Returns an instance of DeleteWarmer class -------------------------------------------------------------------------------- -function DeleteWarmer:new(o) - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -return DeleteWarmer diff --git a/src/elasticsearch/endpoints/Indices/ExistsType.lua b/src/elasticsearch/endpoints/Indices/ExistsType.lua deleted file mode 100644 index b2e6d2c..0000000 --- a/src/elasticsearch/endpoints/Indices/ExistsType.lua +++ /dev/null @@ -1,58 +0,0 @@ -------------------------------------------------------------------------------- --- Importing modules -------------------------------------------------------------------------------- -local IndicesEndpoint = require "elasticsearch.endpoints.Indices.IndicesEndpoint" - -------------------------------------------------------------------------------- --- Declaring module -------------------------------------------------------------------------------- -local ExistsType = IndicesEndpoint:new() - -------------------------------------------------------------------------------- --- Declaring Instance variables -------------------------------------------------------------------------------- - --- The parameters that are allowed to be used in params -ExistsType.allowedParams = { - ["ignore_unavailable"] = true, - ["allow_no_indices"] = true, - ["expand_wildcards"] = true, - ["local"] = true -} - -------------------------------------------------------------------------------- --- Function to calculate the http request method --- --- @return string The HTTP request method -------------------------------------------------------------------------------- -function ExistsType:getMethod() - return "HEAD" -end - -------------------------------------------------------------------------------- --- Function to calculate the URI --- --- @return string The URI -------------------------------------------------------------------------------- -function ExistsType:getUri() - if self.index == nil then - return nil, "index not specified for Exists Type" - end - if self.type == nil then - return nil, "type not specified for Exists Type" - end - local uri = "/" .. self.index .. "/" .. self.type - return uri -end - -------------------------------------------------------------------------------- --- Returns an instance of ExistsType class -------------------------------------------------------------------------------- -function ExistsType:new(o) - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -return ExistsType diff --git a/src/elasticsearch/endpoints/Indices/GetFieldMapping.lua b/src/elasticsearch/endpoints/Indices/GetFieldMapping.lua index da504bd..4c45107 100644 --- a/src/elasticsearch/endpoints/Indices/GetFieldMapping.lua +++ b/src/elasticsearch/endpoints/Indices/GetFieldMapping.lua @@ -45,9 +45,6 @@ function GetFieldMapping:getUri() if self.index ~= nil then uri = "/" .. self.index .. uri end - if self.type ~= nil then - uri = uri .. "/" .. self.type - end uri = uri .. "/field/" .. self.fields diff --git a/src/elasticsearch/endpoints/Indices/GetMapping.lua b/src/elasticsearch/endpoints/Indices/GetMapping.lua index 2cb84e5..c19e093 100644 --- a/src/elasticsearch/endpoints/Indices/GetMapping.lua +++ b/src/elasticsearch/endpoints/Indices/GetMapping.lua @@ -41,10 +41,7 @@ function GetMapping:getUri() if self.index ~= nil then uri = "/" .. self.index .. uri end - if self.type ~= nil then - uri = uri .. "/" .. self.type - end - + return uri end diff --git a/src/elasticsearch/endpoints/Indices/GetWarmer.lua b/src/elasticsearch/endpoints/Indices/GetWarmer.lua deleted file mode 100644 index f904389..0000000 --- a/src/elasticsearch/endpoints/Indices/GetWarmer.lua +++ /dev/null @@ -1,64 +0,0 @@ -------------------------------------------------------------------------------- --- Importing modules -------------------------------------------------------------------------------- -local IndicesEndpoint = require "elasticsearch.endpoints.Indices.IndicesEndpoint" - -------------------------------------------------------------------------------- --- Declaring module -------------------------------------------------------------------------------- -local GetWarmer = IndicesEndpoint:new() - -------------------------------------------------------------------------------- --- Declaring Instance variables -------------------------------------------------------------------------------- - --- The parameters that are allowed to be used in params -GetWarmer.allowedParams = { - ["ignore_unavailable"] = true, - ["allow_no_indices"] = true, - ["expand_wildcards"] = true, - ["local"] = true -} - -------------------------------------------------------------------------------- --- Function to calculate the http request method --- --- @return string The HTTP request method -------------------------------------------------------------------------------- -function GetWarmer:getMethod() - return "GET" -end - -------------------------------------------------------------------------------- --- Function to calculate the URI --- --- @return string The URI -------------------------------------------------------------------------------- -function GetWarmer:getUri() - if self.index ~= nil and self.type ~= nil and self.name == nil then - return nil, "If index and type are specified, then name must also be specified for Get Warmer" - end - - local uri = "/_warmer" - if self.name ~= nil then - uri = uri .. "/" .. self.name - end - if self.type ~= nil and self.index ~= nil then - uri = "/" .. self.index .. "/" .. self.type .. uri - elseif self.index ~= nil then - uri = "/" .. self.index .. uri - end - return uri -end - -------------------------------------------------------------------------------- --- Returns an instance of GetWarmer class -------------------------------------------------------------------------------- -function GetWarmer:new(o) - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -return GetWarmer diff --git a/src/elasticsearch/endpoints/Indices/IndicesEndpoint.lua b/src/elasticsearch/endpoints/Indices/IndicesEndpoint.lua index 20e485a..8431577 100644 --- a/src/elasticsearch/endpoints/Indices/IndicesEndpoint.lua +++ b/src/elasticsearch/endpoints/Indices/IndicesEndpoint.lua @@ -32,7 +32,6 @@ function IndicesEndpoint:setParams(params) -- Clearing parameters self.name = nil self.index = nil - self.type = nil self.fields = nil self.isSynced = nil self.feature = nil @@ -44,8 +43,6 @@ function IndicesEndpoint:setParams(params) self.name = v elseif i == "index" then self.index = v - elseif i == "type" then - self.type = v elseif i == "fields" then self.fields = v elseif i == "sync" then diff --git a/src/elasticsearch/endpoints/Indices/PutMapping.lua b/src/elasticsearch/endpoints/Indices/PutMapping.lua index 819ac58..628a3cd 100644 --- a/src/elasticsearch/endpoints/Indices/PutMapping.lua +++ b/src/elasticsearch/endpoints/Indices/PutMapping.lua @@ -38,11 +38,7 @@ end -- @return string The URI ------------------------------------------------------------------------------- function PutMapping:getUri() - if self.type == nil then - return nil, "Type not specified for Put Mapping" - end - - local uri = "/_mapping/" .. self.type + local uri = "/_mapping" if self.index ~= nil then uri = "/" .. self.index .. uri diff --git a/src/elasticsearch/endpoints/Indices/PutWarmer.lua b/src/elasticsearch/endpoints/Indices/PutWarmer.lua deleted file mode 100644 index d0faca6..0000000 --- a/src/elasticsearch/endpoints/Indices/PutWarmer.lua +++ /dev/null @@ -1,62 +0,0 @@ -------------------------------------------------------------------------------- --- Importing modules -------------------------------------------------------------------------------- -local IndicesEndpoint = require "elasticsearch.endpoints.Indices.IndicesEndpoint" - -------------------------------------------------------------------------------- --- Declaring module -------------------------------------------------------------------------------- -local PutWarmer = IndicesEndpoint:new() - -------------------------------------------------------------------------------- --- Declaring Instance variables -------------------------------------------------------------------------------- - --- The parameters that are allowed to be used in params -PutWarmer.allowedParams = { - ["master_timeout"] = true, - ["ignore_unavailable"] = true, - ["allow_no_indices"] = true, - ["expand_wildcards"] = true, - ["request_cache"] = true -} - -------------------------------------------------------------------------------- --- Function to calculate the http request method --- --- @return string The HTTP request method -------------------------------------------------------------------------------- -function PutWarmer:getMethod() - return "PUT" -end - -------------------------------------------------------------------------------- --- Function to calculate the URI --- --- @return string The URI -------------------------------------------------------------------------------- -function PutWarmer:getUri() - if self.name == nil then - return nil, "name not specified for Put Warmer" - end - - local uri = "/_warmer/" .. self.name - if self.index ~= nil and self.type ~= nil then - uri = "/" .. self.index .. "/" .. self.type .. uri - elseif self.index ~= nil then - uri = "/" .. self.index .. uri - end - return uri -end - -------------------------------------------------------------------------------- --- Returns an instance of PutWarmer class -------------------------------------------------------------------------------- -function PutWarmer:new(o) - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -return PutWarmer diff --git a/src/elasticsearch/endpoints/Indices/ValidateQuery.lua b/src/elasticsearch/endpoints/Indices/ValidateQuery.lua index 8204211..2a78a18 100644 --- a/src/elasticsearch/endpoints/Indices/ValidateQuery.lua +++ b/src/elasticsearch/endpoints/Indices/ValidateQuery.lua @@ -48,9 +48,6 @@ end function ValidateQuery:getUri() local uri = "/_validate/query" - if self.type ~= nil then - uri = "/" .. self.type .. uri - end if self.index ~= nil then uri = "/" .. self.index .. uri end diff --git a/tests/endpoints/IndicesTest/DeleteWarmerTest.lua b/tests/endpoints/IndicesTest/DeleteWarmerTest.lua deleted file mode 100644 index a690edd..0000000 --- a/tests/endpoints/IndicesTest/DeleteWarmerTest.lua +++ /dev/null @@ -1,65 +0,0 @@ --- Importing modules -local DeleteWarmer = require "elasticsearch.endpoints.Indices.DeleteWarmer" -local MockTransport = require "lib.MockTransport" -local getmetatable = getmetatable - --- Setting up environment -local _ENV = lunit.TEST_CASE "tests.endpoints.IndicesTest.DeleteWarmerTest" - --- Declaring local variables -local endpoint -local mockTransport = MockTransport:new() - --- Testing the constructor -function constructorTest() - assert_function(DeleteWarmer.new) - local o = DeleteWarmer:new() - assert_not_nil(o) - local mt = getmetatable(o) - assert_table(mt) - assert_equal(mt, mt.__index) -end - --- The setup function -function setup() - endpoint = DeleteWarmer:new{ - transport = mockTransport - } -end - --- Testing request -function requestTest() - mockTransport.method = "DELETE" - mockTransport.uri = "/users/_warmer/user_12" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "users", - name = "user_12" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing error request -function requestErrorTest() - mockTransport.method = "DELETE" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "test" - } - - local _, err = endpoint:request() - assert_not_nil(err) - - endpoint:setParams{ - name = "name" - } - - local _, err = endpoint:request() - assert_not_nil(err) -end diff --git a/tests/endpoints/IndicesTest/ExistsTypeTest.lua b/tests/endpoints/IndicesTest/ExistsTypeTest.lua deleted file mode 100644 index 6120a97..0000000 --- a/tests/endpoints/IndicesTest/ExistsTypeTest.lua +++ /dev/null @@ -1,66 +0,0 @@ --- Importing modules -local ExistsType = require "elasticsearch.endpoints.Indices.ExistsType" -local MockTransport = require "lib.MockTransport" -local getmetatable = getmetatable - --- Setting up environment -local _ENV = lunit.TEST_CASE "tests.endpoints.IndicesTest.ExistsTypeTest" - --- Declaring local variables -local endpoint -local mockTransport = MockTransport:new() - --- Testing the constructor -function constructorTest() - assert_function(ExistsType.new) - local o = ExistsType:new() - assert_not_nil(o) - local mt = getmetatable(o) - assert_table(mt) - assert_equal(mt, mt.__index) -end - --- The setup function -function setup() - endpoint = ExistsType:new{ - transport = mockTransport - } -end - --- Testing request -function requestTest() - mockTransport.method = "HEAD" - mockTransport.uri = "/twitter/tweet" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "twitter", - type = "tweet" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing error request -function requestErrorTest() - mockTransport.method = "HEAD" - mockTransport.uri = "/twitter/tweet" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "twitter", - } - - local _, err = endpoint:request() - assert_not_nil(err) - - endpoint:setParams{ - type = "tweet", - } - - local _, err = endpoint:request() - assert_not_nil(err) -end diff --git a/tests/endpoints/IndicesTest/GetWarmerTest.lua b/tests/endpoints/IndicesTest/GetWarmerTest.lua deleted file mode 100644 index ed44d73..0000000 --- a/tests/endpoints/IndicesTest/GetWarmerTest.lua +++ /dev/null @@ -1,116 +0,0 @@ --- Importing modules -local GetWarmer = require "elasticsearch.endpoints.Indices.GetWarmer" -local MockTransport = require "lib.MockTransport" -local getmetatable = getmetatable - --- Setting up environment -local _ENV = lunit.TEST_CASE "tests.endpoints.IndicesTest.GetWarmerTest" - --- Declaring local variables -local endpoint -local mockTransport = MockTransport:new() - --- Testing the constructor -function constructorTest() - assert_function(GetWarmer.new) - local o = GetWarmer:new() - assert_not_nil(o) - local mt = getmetatable(o) - assert_table(mt) - assert_equal(mt, mt.__index) -end - --- The setup function -function setup() - endpoint = GetWarmer:new{ - transport = mockTransport - } -end - --- Testing request -function requestTest() - mockTransport.method = "GET" - mockTransport.uri = "/_warmer" - mockTransport.params = {} - mockTransport.body = nil - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing name request -function requestNameTest() - mockTransport.method = "GET" - mockTransport.uri = "/_warmer/user_21" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - name = "user_21" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing index request -function requestIndexTest() - mockTransport.method = "GET" - mockTransport.uri = "/twitter/_warmer" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "twitter" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing type request -function requestTypeTest() - mockTransport.method = "GET" - mockTransport.uri = "/_warmer" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - type = "tweet" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing index, type and name request -function requestIndexTypeNameTest() - mockTransport.method = "GET" - mockTransport.uri = "/twitter/tweet/_warmer/user_21" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "twitter", - type = "tweet", - name = "user_21" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing error request -function requestErrorTest() - mockTransport.method = "GET" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "twitter", - type = "tweet" - } - - local _, err = endpoint:request() - assert_not_nil(err) -end diff --git a/tests/endpoints/IndicesTest/PutWarmerTest.lua b/tests/endpoints/IndicesTest/PutWarmerTest.lua deleted file mode 100644 index 255a59e..0000000 --- a/tests/endpoints/IndicesTest/PutWarmerTest.lua +++ /dev/null @@ -1,107 +0,0 @@ --- Importing modules -local PutWarmer = require "elasticsearch.endpoints.Indices.PutWarmer" -local MockTransport = require "lib.MockTransport" -local getmetatable = getmetatable - --- Setting up environment -local _ENV = lunit.TEST_CASE "tests.endpoints.IndicesTest.PutWarmerTest" - --- Declaring local variables -local endpoint -local mockTransport = MockTransport:new() - --- Testing the constructor -function constructorTest() - assert_function(PutWarmer.new) - local o = PutWarmer:new() - assert_not_nil(o) - local mt = getmetatable(o) - assert_table(mt) - assert_equal(mt, mt.__index) -end - --- The setup function -function setup() - endpoint = PutWarmer:new{ - transport = mockTransport - } -end - --- Testing name request -function requestNameTest() - mockTransport.method = "PUT" - mockTransport.uri = "/_warmer/user_21" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - name = "user_21" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing index name request -function requestIndexNameTest() - mockTransport.method = "PUT" - mockTransport.uri = "/twitter/_warmer/user_21" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "twitter", - name = "user_21" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing type name request -function requestTypeNameTest() - mockTransport.method = "PUT" - mockTransport.uri = "/_warmer/user_21" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - type = "tweet", - name = "user_21" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing index, type and name request -function requestIndexTypeNameTest() - mockTransport.method = "PUT" - mockTransport.uri = "/twitter/tweet/_warmer/user_21" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "twitter", - type = "tweet", - name = "user_21" - } - - local _, err = endpoint:request() - assert_nil(err) -end - --- Testing error request -function requestErrorTest() - mockTransport.method = "PUT" - mockTransport.params = {} - mockTransport.body = nil - - endpoint:setParams{ - index = "twitter", - type = "tweet" - } - - local _, err = endpoint:request() - assert_not_nil(err) -end diff --git a/tests/endpoints/IndicesTest/init.lua b/tests/endpoints/IndicesTest/init.lua index d3299ce..68ee2fb 100644 --- a/tests/endpoints/IndicesTest/init.lua +++ b/tests/endpoints/IndicesTest/init.lua @@ -16,13 +16,9 @@ require "endpoints.IndicesTest.DeleteTemplateTest" require "endpoints.IndicesTest.ExistsTemplateTest" require "endpoints.IndicesTest.GetTemplateTest" require "endpoints.IndicesTest.PutTemplateTest" -require "endpoints.IndicesTest.ExistsTypeTest" require "endpoints.IndicesTest.GetUpgradeTest" require "endpoints.IndicesTest.PostUpgradeTest" require "endpoints.IndicesTest.ValidateQueryTest" -require "endpoints.IndicesTest.DeleteWarmerTest" -require "endpoints.IndicesTest.GetWarmerTest" -require "endpoints.IndicesTest.PutWarmerTest" require "endpoints.IndicesTest.AnalyzeTest" require "endpoints.IndicesTest.CloseTest" require "endpoints.IndicesTest.CreateTest"