aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core/managers/opam_spec.lua
blob: 143e4dac58dbc71c9c65d0e55c135292d2f13767 (plain) (blame)
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
local match = require "luassert.match"
local mock = require "luassert.mock"
local Optional = require "mason-core.optional"
local installer = require "mason-core.installer"
local opam = require "mason-core.managers.opam"

describe("opam manager", function()
    it(
        "should call opam install",
        async_test(function()
            local handle = InstallHandleGenerator "dummy"
            local ctx = InstallContextGenerator(handle, { requested_version = "42.13.37" })
            installer.run_installer(ctx, opam.packages { "main-package", "supporting-package", "supporting-package2" })
            assert.spy(ctx.spawn.opam).was_called(1)
            assert.spy(ctx.spawn.opam).was_called_with(match.tbl_containing {
                "install",
                "--destdir=.",
                "--yes",
                "--verbose",
                match.tbl_containing {
                    "main-package.42.13.37",
                    "supporting-package",
                    "supporting-package2",
                },
            })
        end)
    )

    it(
        "should provide receipt information",
        async_test(function()
            local handle = InstallHandleGenerator "dummy"
            local ctx = InstallContextGenerator(handle, { requested_version = "42.13.37" })
            installer.run_installer(ctx, opam.packages { "main-package", "supporting-package", "supporting-package2" })
            assert.same({
                type = "opam",
                package = "main-package",
            }, ctx.receipt.primary_source)
            assert.same({
                {
                    type = "opam",
                    package = "supporting-package",
                },
                {
                    type = "opam",
                    package = "supporting-package2",
                },
            }, ctx.receipt.secondary_sources)
        end)
    )
end)