aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core/installer/managers/nuget_spec.lua
blob: 2f16a6524e388fe91f9d258700dca54f2560f421 (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
local match = require "luassert.match"
local nuget = require "mason-core.installer.managers.nuget"
local spy = require "luassert.spy"
local test_helpers = require "mason-test.helpers"

describe("nuget manager", function()
    it("should install", function()
        local ctx = test_helpers.create_context()
        ctx:execute(function()
            nuget.install("nuget-package", "1.0.0")
        end)

        assert.spy(ctx.spawn.dotnet).was_called(1)
        assert.spy(ctx.spawn.dotnet).was_called_with {
            "tool",
            "update",
            "--tool-path",
            ".",
            { "--version", "1.0.0" },
            "nuget-package",
        }
    end)

    it("should write output", function()
        local ctx = test_helpers.create_context()
        spy.on(ctx.stdio_sink, "stdout")

        ctx:execute(function()
            nuget.install("nuget-package", "1.0.0")
        end)

        assert
            .spy(ctx.stdio_sink.stdout)
            .was_called_with(match.is_ref(ctx.stdio_sink), "Installing nuget package nuget-package@1.0.0…\n")
    end)
end)