diff options
| author | William Boman <william@redwill.se> | 2023-09-11 00:05:44 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2025-02-16 09:32:29 +0100 |
| commit | 2275067747a118d6002f421cb54f28affbc0ef98 (patch) | |
| tree | 79bc1c2580ba96cc1b19e71f2b31f7c4c8ab490c /tests/mason-core/managers/powershell_spec.lua | |
| parent | chore(main): release 1.11.0 (#1658) (diff) | |
| download | mason-2275067747a118d6002f421cb54f28affbc0ef98.tar mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.gz mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.bz2 mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.lz mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.xz mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.zst mason-2275067747a118d6002f421cb54f28affbc0ef98.zip | |
refactor!: remove old managers (#1497)
Diffstat (limited to 'tests/mason-core/managers/powershell_spec.lua')
| -rw-r--r-- | tests/mason-core/managers/powershell_spec.lua | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/tests/mason-core/managers/powershell_spec.lua b/tests/mason-core/managers/powershell_spec.lua deleted file mode 100644 index 56ec243e..00000000 --- a/tests/mason-core/managers/powershell_spec.lua +++ /dev/null @@ -1,91 +0,0 @@ -local match = require "luassert.match" -local mock = require "luassert.mock" -local spawn = require "mason-core.spawn" -local spy = require "luassert.spy" -local stub = require "luassert.stub" - -describe("powershell manager", function() - local function powershell() - package.loaded["mason-core.managers.powershell"] = nil - return require "mason-core.managers.powershell" - end - - it("should use pwsh if available", function() - stub(spawn, "pwsh", function() end) - stub(spawn, "powershell", function() end) - stub(vim.fn, "executable") - vim.fn.executable.on_call_with("pwsh").returns(1) - - powershell().command "echo 'Is this bash?'" - - assert.spy(spawn.pwsh).was_called(1) - assert.spy(spawn.powershell).was_called(0) - end) - - it( - "should use powershell if pwsh is not available", - async_test(function() - stub(spawn, "pwsh", function() end) - stub(spawn, "powershell", function() end) - stub(vim.fn, "executable") - vim.fn.executable.on_call_with("pwsh").returns(0) - - local powershell = powershell() - powershell.command "echo 'Is this bash?'" - - assert.spy(spawn.pwsh).was_called(0) - assert.spy(spawn.powershell).was_called(1) - end) - ) - - it("should use the provided spawner for commands", function() - spy.on(spawn, "pwsh") - local custom_spawn = mock.new { pwsh = mockx.just_runs } - stub(vim.fn, "executable") - vim.fn.executable.on_call_with("pwsh").returns(1) - powershell().command("echo 'Is this bash?'", {}, custom_spawn) - - assert.spy(spawn.pwsh).was_called(0) - assert.spy(custom_spawn.pwsh).was_called(1) - end) - - it("should provide default powershell options via command interface", function() - stub(spawn, "pwsh", function() end) - stub(vim.fn, "executable") - vim.fn.executable.on_call_with("pwsh").returns(1) - - powershell().command "echo 'Is this bash?'" - - assert.spy(spawn.pwsh).was_called(1) - assert.spy(spawn.pwsh).was_called_with(match.tbl_containing { - "-NoProfile", - "-NonInteractive", - "-Command", - [[ $ErrorActionPreference = "Stop"; $ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; echo 'Is this bash?']], - }) - end) - - it("should close stdin", function() - local stdin = { - close = spy.new(), - } - stub( - spawn, - "pwsh", - ---@param args SpawnArgs - function(args) - args.on_spawn(mock.new(), { - stdin, - }, 1) - end - ) - stub(vim.fn, "executable") - vim.fn.executable.on_call_with("pwsh").returns(1) - - powershell().command "Powershell-Command" - - assert.spy(spawn.pwsh).was_called(1) - assert.spy(stdin.close).was_called(1) - assert.spy(stdin.close).was_called_with(match.is_ref(stdin)) - end) -end) |
