1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
local installer = require "mason-core.installer"
local luarocks = require "mason-core.managers.luarocks"
local path = require "mason-core.path"
describe("luarocks manager", function()
it(
"should install provided package",
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
installer.run_installer(ctx, luarocks.package "lua-cjson")
assert.spy(ctx.spawn.luarocks).was_called(1)
assert.spy(ctx.spawn.luarocks).was_called_with {
"install",
"--tree",
path.package_prefix "dummy",
vim.NIL, -- --dev flag
vim.NIL, -- --server flag
"lua-cjson",
vim.NIL, -- version
}
end)
)
it(
"should install provided version",
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { requested_version = "1.2.3" })
installer.run_installer(ctx, luarocks.package "lua-cjson")
assert.spy(ctx.spawn.luarocks).was_called(1)
assert.spy(ctx.spawn.luarocks).was_called_with {
"install",
"--tree",
path.package_prefix "dummy",
vim.NIL, -- --dev flag
vim.NIL, -- --server flag
"lua-cjson",
"1.2.3",
}
end)
)
it(
"should provide --dev flag",
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
installer.run_installer(ctx, luarocks.package("lua-cjson", { dev = true }))
assert.spy(ctx.spawn.luarocks).was_called(1)
assert.spy(ctx.spawn.luarocks).was_called_with {
"install",
"--tree",
path.package_prefix "dummy",
"--dev",
vim.NIL, -- --server flag
"lua-cjson",
vim.NIL, -- version
}
end)
)
it(
"should provide --server flag",
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
installer.run_installer(ctx, luarocks.package("luaformatter", { server = "https://luarocks.org/dev" }))
assert.spy(ctx.spawn.luarocks).was_called(1)
assert.spy(ctx.spawn.luarocks).was_called_with {
"install",
"--tree",
path.package_prefix "dummy",
vim.NIL, -- --dev flag
"--server=https://luarocks.org/dev",
"luaformatter",
vim.NIL, -- version
}
end)
)
it("should parse outdated luarocks", function()
assert.same(
{
{
name = "lua-cjson",
installed = "2.1.0-1",
available = "2.1.0.6-1",
repo = "https://luarocks.org",
},
{
name = "lua-resty-influx-mufanh",
installed = "0.2.1-0",
available = "0.2.1-1",
repo = "https://luarocks.org",
},
},
luarocks.parse_outdated_rocks [[lua-cjson 2.1.0-1 2.1.0.6-1 https://luarocks.org
lua-resty-influx-mufanh 0.2.1-0 0.2.1-1 https://luarocks.org]]
)
end)
it("should parse listed luarocks", function()
assert.same(
{
{
package = "lua-cjson",
version = "2.1.0-1",
arch = "installed",
nrepo = "/my/luarock/loc",
},
{
package = "lua-resty-http",
version = "0.17.0.beta.1-0",
arch = "installed",
nrepo = "/my/luarock/loc",
},
{
package = "lua-resty-influx-mufanh",
version = "0.2.1-0",
arch = "installed",
nrepo = "/my/luarock/loc",
},
},
luarocks.parse_installed_rocks [[lua-cjson 2.1.0-1 installed /my/luarock/loc
lua-resty-http 0.17.0.beta.1-0 installed /my/luarock/loc
lua-resty-influx-mufanh 0.2.1-0 installed /my/luarock/loc]]
)
end)
end)
|