aboutsummaryrefslogtreecommitdiff
path: root/spec/pack_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/pack_spec.lua')
-rw-r--r--spec/pack_spec.lua76
1 files changed, 54 insertions, 22 deletions
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua
index 86b4e2b2..54d139e0 100644
--- a/spec/pack_spec.lua
+++ b/spec/pack_spec.lua
@@ -5,57 +5,89 @@ local testing_paths = test_env.testing_paths
5 5
6test_env.unload_luarocks() 6test_env.unload_luarocks()
7 7
8local extra_rocks = { 8local extra_rocks = test_env.mock_server_extra_rocks({
9 "/luasec-0.6-1.rockspec", 9 "/luasec-0.6-1.rockspec",
10 "/luassert-1.7.0-1.src.rock", 10 "/luassert-1.7.0-1.src.rock",
11 "/luasocket-3.0rc1-2.src.rock", 11 "/luasocket-3.0rc1-2.src.rock",
12 "/luasocket-3.0rc1-2.rockspec", 12 "/luasocket-3.0rc1-2.rockspec",
13 "/say-1.2-1.src.rock", 13 "/say-1.2-1.src.rock",
14 "/say-1.0-1.src.rock" 14 "/say-1.0-1.src.rock"
15} 15})
16 16
17describe("LuaRocks pack tests #blackbox #b_pack", function() 17describe("LuaRocks pack #blackbox #b_pack", function()
18 18
19 before_each(function() 19 before_each(function()
20 test_env.setup_specs(extra_rocks) 20 test_env.setup_specs(extra_rocks)
21 end) 21 end)
22 22
23 it("LuaRocks pack with no flags/arguments", function() 23 it("with no flags/arguments", function()
24 assert.is_false(run.luarocks_bool("pack")) 24 assert.is_false(run.luarocks_bool("pack"))
25 end) 25 end)
26 26
27 it("LuaRocks pack basic", function() 27 it("basic", function()
28 assert.is_true(run.luarocks_bool("pack luacov")) 28 assert(run.luarocks_bool("pack luacov"))
29 assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov%-")) 29 assert(test_env.remove_files(lfs.currentdir(), "luacov%-"))
30 end) 30 end)
31 31
32 it("LuaRocks pack invalid rockspec", function() 32 it("invalid rockspec", function()
33 assert.is_false(run.luarocks_bool("pack " .. testing_paths.fixtures_dir .. "/invaild_validate-args-1.5.4-1.rockspec")) 33 assert.is_false(run.luarocks_bool("pack " .. testing_paths.fixtures_dir .. "/invalid_validate-args-1.5.4-1.rockspec"))
34 end) 34 end)
35 35
36 it("LuaRocks pack not installed rock", function() 36 it("not installed rock", function()
37 assert.is_false(run.luarocks_bool("pack cjson")) 37 assert.is_false(run.luarocks_bool("pack cjson"))
38 end) 38 end)
39 39
40 it("LuaRocks pack not installed rock from non existing manifest", function() 40 it("not installed rock from non existing manifest", function()
41 assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) 41 assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif"))
42 end) 42 end)
43 43
44 it("LuaRocks pack detects latest version version of rock", function() 44 it("detects latest version version of rock", function()
45 assert.is_true(run.luarocks_bool("install say 1.2")) 45 assert(run.luarocks_bool("install say 1.2"))
46 assert.is_true(run.luarocks_bool("install luassert")) 46 assert(run.luarocks_bool("install luassert"))
47 assert.is_true(run.luarocks_bool("install say 1.0")) 47 assert(run.luarocks_bool("install say 1.0"))
48 assert.is_true(run.luarocks_bool("pack say")) 48 assert(run.luarocks_bool("pack say"))
49 assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) 49 assert.is_truthy(lfs.attributes("say-1.2-1.all.rock"))
50 assert.is_true(test_env.remove_files(lfs.currentdir(), "say%-")) 50 assert(test_env.remove_files(lfs.currentdir(), "say%-"))
51 end) 51 end)
52 52
53 it("LuaRocks pack src", function() 53 it("src", function()
54 assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) 54 assert(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS))
55 assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2")) 55 assert(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2"))
56 assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec")) 56 assert(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec"))
57 assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket%-")) 57 assert(test_env.remove_files(lfs.currentdir(), "luasocket%-"))
58 end) 58 end)
59
60 describe("#mock namespaced dependencies", function()
61
62 setup(function()
63 test_env.mock_server_init()
64 end)
65
66 teardown(function()
67 test_env.mock_server_done()
68 end)
69
70 it("can pack rockspec with namespaced dependencies", function()
71 finally(function()
72 os.remove("has_namespaced_dep-1.0-1.src.rock")
73 end)
74 assert(run.luarocks_bool("pack " .. testing_paths.fixtures_dir .. "/a_repo/has_namespaced_dep-1.0-1.rockspec"))
75 assert.is_truthy(lfs.attributes("has_namespaced_dep-1.0-1.src.rock"))
76 end)
77 end)
78
79 describe("#namespaces", function()
80 it("packs a namespaced rock", function()
81 finally(function()
82 os.remove("a_rock-2.0-1.all.rock")
83 end)
84 assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
85 assert(run.luarocks_bool("build a_rock --keep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
86 assert(run.luarocks_bool("pack a_user/a_rock" ))
87 assert(lfs.attributes("a_rock-2.0-1.all.rock"))
88 end)
89 end)
90
59end) 91end)
60 92
61 93