From 5aa06d43a86754f30347813803f2a9eb6f99a611 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 8 Oct 2017 14:57:41 -0400 Subject: Tests: move mock-server utils into test_environment.lua This avoids trouble with changing package.paths during tests. --- test/test_environment.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'test/test_environment.lua') diff --git a/test/test_environment.lua b/test/test_environment.lua index 56b394cd..a663c1c3 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua @@ -685,6 +685,43 @@ local function install_luarocks(install_env_vars) print("LuaRocks installed correctly!") end +function test_env.mock_server_extra_rocks(more) + local rocks = { + -- rocks needed for mock-server + "/copas-2.0.1-1.src.rock", + "/coxpcall-1.16.0-1.src.rock", + "/dkjson-2.5-2.src.rock", + "/luafilesystem-1.6.3-1.src.rock", + "/luasec-0.6-1.rockspec", + "/luasocket-3.0rc1-2.src.rock", + "/luasocket-3.0rc1-2.rockspec", + "/restserver-0.1-1.src.rock", + "/restserver-xavante-0.2-1.src.rock", + "/rings-1.3.0-1.src.rock", + "/wsapi-1.6.1-1.src.rock", + "/wsapi-xavante-1.6.1-1.src.rock", + "/xavante-2.4.0-1.src.rock" + } + if more then + for _, rock in ipairs(more) do + table.insert(rocks, rock) + end + end + return rocks +end + +function test_env.mock_server_init() + local assert = require("luassert") + local testing_paths = test_env.testing_paths + assert.is_true(test_env.need_rock("restserver-xavante")) + local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.testing_dir .. "/mock-server.lua &", true, test_env.env_variables) + os.execute(final_command) +end + +function test_env.mock_server_done() + os.execute("curl localhost:8080/shutdown") +end + --- -- Main function to create config files and testing environment function test_env.main() -- cgit v1.2.3-55-g6feb