diff options
Diffstat (limited to 'spec/upload_spec.lua')
-rw-r--r-- | spec/upload_spec.lua | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua new file mode 100644 index 00000000..c68a1cdf --- /dev/null +++ b/spec/upload_spec.lua | |||
@@ -0,0 +1,74 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local run = test_env.run | ||
3 | local testing_paths = test_env.testing_paths | ||
4 | |||
5 | test_env.unload_luarocks() | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/lua-cjson-2.1.0-1.src.rock", | ||
9 | |||
10 | -- rocks needed for mock-server | ||
11 | "/copas-2.0.1-1.src.rock", | ||
12 | "/coxpcall-1.16.0-1.src.rock", | ||
13 | "/dkjson-2.5-2.src.rock", | ||
14 | "/luafilesystem-1.6.3-1.src.rock", | ||
15 | "/luasec-0.6-1.rockspec", | ||
16 | "/luasocket-3.0rc1-2.src.rock", | ||
17 | "/luasocket-3.0rc1-2.rockspec", | ||
18 | "/restserver-0.1-1.src.rock", | ||
19 | "/restserver-xavante-0.2-1.src.rock", | ||
20 | "/rings-1.3.0-1.src.rock", | ||
21 | "/wsapi-1.6.1-1.src.rock", | ||
22 | "/wsapi-xavante-1.6.1-1.src.rock", | ||
23 | "/xavante-2.4.0-1.src.rock" | ||
24 | } | ||
25 | |||
26 | describe("LuaRocks upload tests #blackbox #b_upload", function() | ||
27 | |||
28 | before_each(function() | ||
29 | test_env.setup_specs(extra_rocks) | ||
30 | end) | ||
31 | |||
32 | it("LuaRocks upload with no flags/arguments", function() | ||
33 | assert.is_false(run.luarocks_bool("upload")) | ||
34 | end) | ||
35 | |||
36 | it("LuaRocks upload invalid rockspec", function() | ||
37 | assert.is_false(run.luarocks_bool("upload invalid.rockspec")) | ||
38 | end) | ||
39 | |||
40 | it("LuaRocks upload api key invalid", function() | ||
41 | assert.is_false(run.luarocks_bool("upload --api-key=invalid invalid.rockspec")) | ||
42 | end) | ||
43 | |||
44 | it("LuaRocks upload api key invalid and skip-pack", function() | ||
45 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec")) | ||
46 | end) | ||
47 | |||
48 | it("LuaRocks upload force", function() | ||
49 | assert.is_true(run.luarocks_bool("install lua-cjson")) | ||
50 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec")) | ||
51 | assert.is_true(run.luarocks_bool("install lua-cjson")) | ||
52 | end) | ||
53 | |||
54 | describe("LuaRocks upload tests with Xavante server #mock", function() | ||
55 | before_each(function() | ||
56 | assert.is.truthy(test_env.need_rock("restserver-xavante")) | ||
57 | local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.testing_dir .. "/mock-server.lua &", true, test_env.env_variables) | ||
58 | os.execute(final_command) | ||
59 | end) | ||
60 | |||
61 | after_each(function() | ||
62 | os.execute("curl localhost:8080/shutdown") | ||
63 | end) | ||
64 | |||
65 | it("LuaRocks upload rockspec with api-key", function() | ||
66 | assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) | ||
67 | end) | ||
68 | it("LuaRocks upload rockspec with api-key and skip-pack", function() | ||
69 | assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) | ||
70 | end) | ||
71 | end) | ||
72 | end) | ||
73 | |||
74 | |||