From feedb79595885c8f86ad412ef561f05664da7c14 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 8 Oct 2017 01:31:21 -0300 Subject: Tests: use local fixture for upload test. Do not hit the github repository for LuaSocket in upload test. --- spec/upload_spec.lua | 4 ++-- test/mock-server.lua | 17 +++++++++++++++++ test/testfiles/a_rock-1.0-1.rockspec | 17 +++++++++++++++++ test/testfiles/a_rock.lua | 1 + 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 test/testfiles/a_rock-1.0-1.rockspec create mode 100644 test/testfiles/a_rock.lua diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index 6ec8e302..4091bbc9 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -60,10 +60,10 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() end) it("LuaRocks upload rockspec with api-key", function() - assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.OPENSSL_DIRS .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + 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"})) end) it("LuaRocks upload rockspec with api-key and skip-pack", function() - assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.OPENSSL_DIRS .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + assert.is_true(run.luarocks_bool("upload --skip-pack " .. 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"})) end) end) end) diff --git a/test/mock-server.lua b/test/mock-server.lua index 797e2bc5..dbbdea2c 100644 --- a/test/mock-server.lua +++ b/test/mock-server.lua @@ -64,6 +64,23 @@ server:add_resource("/api/1/{id:[0-9]+}/upload_rock/{id:[0-9]+}", { } }) +server:add_resource("/file/{name:[^/]+}", { + { + method = "GET", + path = "/", + produces = "text/plain", + handler = function(query, name) + local fd = io.open("test/testfiles/"..name, "r") + if not fd then + return restserver.response():status(404) + end + local data = fd:read("*a") + fd:close() + return restserver.response():status(200):entity(data) + end + } +}) + -- SHUTDOWN this mock-server server:add_resource("/shutdown", { { diff --git a/test/testfiles/a_rock-1.0-1.rockspec b/test/testfiles/a_rock-1.0-1.rockspec new file mode 100644 index 00000000..9f15e87a --- /dev/null +++ b/test/testfiles/a_rock-1.0-1.rockspec @@ -0,0 +1,17 @@ +package = "a_rock" +version = "1.0-1" +source = { + url = "http://localhost:8080/file/a_rock.lua" +} +description = { + summary = "An example rockspec", +} +dependencies = { + "lua >= 5.1" +} +build = { + type = "builtin", + modules = { + build = "a_rock.lua" + }, +} diff --git a/test/testfiles/a_rock.lua b/test/testfiles/a_rock.lua new file mode 100644 index 00000000..a5647075 --- /dev/null +++ b/test/testfiles/a_rock.lua @@ -0,0 +1 @@ +return {} -- cgit v1.2.3-55-g6feb