aboutsummaryrefslogtreecommitdiffstats
path: root/tests/core/managers/dotnet_spec.lua
blob: 8bc4bf06dc53ccb14da25c560b7240903b2db811 (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
local mock = require "luassert.mock"
local Optional = require "nvim-lsp-installer.core.optional"
local installer = require "nvim-lsp-installer.core.installer"
local dotnet = require "nvim-lsp-installer.core.managers.dotnet"

describe("dotnet manager", function()
    ---@type InstallContext
    local ctx
    before_each(function()
        ctx = InstallContextGenerator {
            spawn = mock.new {
                dotnet = mockx.returns {},
            },
        }
    end)

    it(
        "should call dotnet tool update",
        async_test(function()
            ctx.requested_version = Optional.of "42.13.37"
            installer.run_installer(ctx, dotnet.package "main-package")
            assert.spy(ctx.spawn.dotnet).was_called(1)
            assert.spy(ctx.spawn.dotnet).was_called_with {
                "tool",
                "update",
                "--tool-path",
                ".",
                { "--version", "42.13.37" },
                "main-package",
            }
        end)
    )

    it(
        "should provide receipt information",
        async_test(function()
            ctx.requested_version = Optional.of "42.13.37"
            installer.run_installer(ctx, dotnet.package "main-package")
            assert.equals(
                vim.inspect {
                    type = "dotnet",
                    package = "main-package",
                },
                vim.inspect(ctx.receipt.primary_source)
            )
        end)
    )
end)