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. --- spec/new_version_spec.lua | 7 +++---- spec/upload_spec.lua | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'spec') diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua index 6b2e2147..29449ff5 100644 --- a/spec/new_version_spec.lua +++ b/spec/new_version_spec.lua @@ -1,12 +1,11 @@ local test_env = require("test/test_environment") -local test_mock_server = require("test/test_mock_server") local lfs = require("lfs") local run = test_env.run local testing_paths = test_env.testing_paths test_env.unload_luarocks() -local extra_rocks = test_mock_server.extra_rocks({ +local extra_rocks = test_env.mock_server_extra_rocks({ "/abelhas-1.0-1.rockspec", "/lpeg-0.12-1.rockspec" }) @@ -38,12 +37,12 @@ describe("LuaRocks new_version tests #blackbox #b_new_version", function() describe("LuaRocks new_version more complex tests", function() it("LuaRocks new version with remote spec", function() - test_mock_server.init() + test_env.mock_server_init() assert.is_true(run.luarocks_bool("new_version http://localhost:8080/file/a_rock-1.0-1.rockspec")) assert.is.truthy(lfs.attributes("a_rock-1.0-1.rockspec")) assert.is.truthy(lfs.attributes("a_rock-1.0-2.rockspec")) test_env.remove_files(lfs.currentdir(), "luasocket--") - test_mock_server.done() + test_env.mock_server_done() end) it("LuaRocks new_version of luacov", function() diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index cf915eb3..b8e147e0 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -1,11 +1,10 @@ local test_env = require("test/test_environment") -local test_mock_server = require("test/test_mock_server") local run = test_env.run local testing_paths = test_env.testing_paths test_env.unload_luarocks() -local extra_rocks = test_mock_server.extra_rocks() +local extra_rocks = test_env.mock_server_extra_rocks() describe("LuaRocks upload tests #blackbox #b_upload", function() @@ -35,9 +34,9 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() end) describe("LuaRocks upload tests with Xavante server #mock", function() - before_each(test_mock_server.init) + before_each(test_env.mock_server_init) - after_each(test_mock_server.done) + after_each(test_env.mock_server_done) it("LuaRocks upload rockspec with api-key", function() assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_dir .. "/testfiles/a_rock-1.0-1.rockspec " .. test_env.OPENSSL_DIRS .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) -- cgit v1.2.3-55-g6feb