-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: support
roles.httpd
integration
Since the `httpd` role was released this role has been needed support for this feature. After the patch metrics-export-role supports an `httpd` role. It is possible to determine a list of servers that role will reuse in the following configuration. Closes #15
- Loading branch information
1 parent
4c7758c
commit 4689696
Showing
8 changed files
with
1,279 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- M is a mocks module that uses for changing methods behaviour. | ||
-- It could be useful in unit tests when we neeed to determine | ||
-- behaviour of methods that we don't need to test in it. | ||
local M = {} | ||
|
||
local validate = function(mocks) | ||
if type(mocks) ~= "table" then | ||
error("mocks should have a table type, got " .. type(mocks)) | ||
end | ||
|
||
for _, mock in ipairs(mocks) do | ||
if type(mock.module) ~= "string" then | ||
error("module name should have a string type, got " .. type(mock.module)) | ||
end | ||
local ok, _ = pcall(require, mock.module) | ||
if not ok then | ||
error("cannot require module " .. mock.module) | ||
end | ||
|
||
if type(mock.method) ~= "string" then | ||
error("method name should have a string type, got " .. type(mock.method)) | ||
end | ||
if require(mock.module)[mock.method] == nil then | ||
error("there is no method called " .. mock.method .. " in " .. mock.module) | ||
end | ||
|
||
if type(mock.implementation) ~= "function" then | ||
error("implementation type should be a function, got " .. mock.implementation) | ||
end | ||
end | ||
end | ||
|
||
-- M.apply validates mocks, initializes it and if everything | ||
-- is fine replaces methods from initialized list. | ||
M.apply = function(mocks) | ||
validate(mocks) | ||
M.mocks = mocks | ||
|
||
for _, mock in ipairs(M.mocks) do | ||
mock.original_implementation = require(mock.module)[mock.method] | ||
require(mock.module)[mock.method] = mock.implementation | ||
end | ||
end | ||
|
||
-- M.delete returns original implementation from mocked method. | ||
M.clear = function() | ||
for _, mock in ipairs(M.mocks) do | ||
require(mock.module)[mock.method] = mock.original_implementation | ||
end | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.