aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-06 00:25:50 +0200
committerGitHub <noreply@github.com>2022-04-06 00:25:50 +0200
commit999476c324b26223aaf409a84497215e18d74499 (patch)
tree323cc5b072471e5e78ee94b273157779bbcb9611 /tests/helpers
parentfix(taplo): use crate distribution (#576) (diff)
downloadmason-999476c324b26223aaf409a84497215e18d74499.tar
mason-999476c324b26223aaf409a84497215e18d74499.tar.gz
mason-999476c324b26223aaf409a84497215e18d74499.tar.bz2
mason-999476c324b26223aaf409a84497215e18d74499.tar.lz
mason-999476c324b26223aaf409a84497215e18d74499.tar.xz
mason-999476c324b26223aaf409a84497215e18d74499.tar.zst
mason-999476c324b26223aaf409a84497215e18d74499.zip
switch majority of installers to async implementation (#574)
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/lua/test_helpers.lua21
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/helpers/lua/test_helpers.lua b/tests/helpers/lua/test_helpers.lua
index 23353fcb..206337e1 100644
--- a/tests/helpers/lua/test_helpers.lua
+++ b/tests/helpers/lua/test_helpers.lua
@@ -6,7 +6,6 @@ local a = require "nvim-lsp-installer.core.async"
local process = require "nvim-lsp-installer.process"
local server = require "nvim-lsp-installer.server"
local Optional = require "nvim-lsp-installer.core.optional"
-local Result = require "nvim-lsp-installer.core.result"
local receipt = require "nvim-lsp-installer.core.receipt"
function async_test(suspend_fn)
@@ -38,18 +37,18 @@ function ServerGenerator(opts)
languages = { "dummylang" },
root_dir = server.get_server_root_path "dummy",
homepage = "https://dummylang.org",
- installer = function(_, callback, ctx)
+ async = true,
+ installer = function(ctx)
ctx.stdio_sink.stdout "Installing dummy!\n"
- callback(true)
end,
}, opts))
end
function FailingServerGenerator(opts)
return ServerGenerator(vim.tbl_deep_extend("force", {
- installer = function(_, callback, ctx)
+ installer = function(ctx)
ctx.stdio_sink.stdout "Installing failing dummy!\n"
- callback(false)
+ error "Failed to do something."
end,
}, opts))
end
@@ -57,16 +56,20 @@ end
function InstallContextGenerator(opts)
---@type InstallContext
local default_opts = {
+ name = "mock",
fs = mock.new {
append_file = mockx.just_runs,
dir_exists = mockx.returns(true),
file_exists = mockx.returns(true),
},
spawn = mock.new {},
- cwd = function()
- return "/tmp/install-dir"
- end,
- promote_cwd = mockx.returns(Result.success()),
+ cwd = mock.new {
+ get = mockx.returns "/tmp/install-dir",
+ set = mockx.just_runs,
+ },
+ destination_dir = "/opt/install-dir",
+ stdio_sink = process.empty_sink(),
+ promote_cwd = mockx.just_runs,
receipt = receipt.InstallReceiptBuilder.new(),
requested_version = Optional.empty(),
}