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
|
local golang = require "mason-core.installer.managers.golang"
local match = require "luassert.match"
local spy = require "luassert.spy"
local test_helpers = require "mason-test.helpers"
describe("golang manager", function()
it("should install", function()
local ctx = test_helpers.create_context()
ctx:execute(function()
golang.install("my-golang", "1.0.0")
end)
assert.spy(ctx.spawn.go).was_called(1)
assert.spy(ctx.spawn.go).was_called_with {
"install",
"-v",
"my-golang@1.0.0",
env = {
GOBIN = ctx.cwd:get(),
},
}
end)
it("should write output", function()
local ctx = test_helpers.create_context()
spy.on(ctx.stdio_sink, "stdout")
ctx:execute(function()
golang.install("my-golang", "1.0.0")
end)
assert
.spy(ctx.stdio_sink.stdout)
.was_called_with(match.is_ref(ctx.stdio_sink), "Installing go package my-golang@1.0.0…\n")
end)
it("should install extra packages", function()
local ctx = test_helpers.create_context()
ctx:execute(function()
golang.install("my-golang", "1.0.0", {
extra_packages = { "extra", "package" },
})
end)
assert.spy(ctx.spawn.go).was_called(3)
assert.spy(ctx.spawn.go).was_called_with {
"install",
"-v",
"my-golang@1.0.0",
env = {
GOBIN = ctx.cwd:get(),
},
}
assert.spy(ctx.spawn.go).was_called_with {
"install",
"-v",
"extra@latest",
env = {
GOBIN = ctx.cwd:get(),
},
}
assert.spy(ctx.spawn.go).was_called_with {
"install",
"-v",
"package@latest",
env = {
GOBIN = ctx.cwd:get(),
},
}
end)
end)
|