aboutsummaryrefslogtreecommitdiffstats
path: root/tests/core
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-21 12:09:59 +0200
committerGitHub <noreply@github.com>2022-04-21 12:09:59 +0200
commitb68fcc6bb2c770495ff8e2508c06dfdd49abcc80 (patch)
treedf7c71efb59958deb21a18eeccf3e3c43c4cd704 /tests/core
parentrun autogen_metadata.lua (diff)
downloadmason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.gz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.bz2
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.lz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.xz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.zst
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.zip
chore: refactor remaining installers to async impl (#616)
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/fs_spec.lua24
-rw-r--r--tests/core/managers/gem_spec.lua18
-rw-r--r--tests/core/managers/git_spec.lua2
-rw-r--r--tests/core/managers/go_spec.lua19
-rw-r--r--tests/core/spawn_spec.lua15
5 files changed, 52 insertions, 26 deletions
diff --git a/tests/core/fs_spec.lua b/tests/core/fs_spec.lua
new file mode 100644
index 00000000..121c57d6
--- /dev/null
+++ b/tests/core/fs_spec.lua
@@ -0,0 +1,24 @@
+local fs = require "nvim-lsp-installer.core.fs"
+local lsp_installer = require "nvim-lsp-installer"
+
+describe("fs", function()
+ before_each(function()
+ lsp_installer.settings {
+ install_root_dir = "/foo",
+ }
+ end)
+
+ it(
+ "refuses to rmrf paths outside of boundary",
+ async_test(function()
+ local e = assert.has.errors(function()
+ fs.rmrf "/thisisa/path"
+ end)
+
+ assert.equal(
+ [[Refusing to rmrf "/thisisa/path" which is outside of the allowed boundary "/foo". Please report this error at https://github.com/williamboman/nvim-lsp-installer/issues/new]],
+ e
+ )
+ end)
+ )
+end)
diff --git a/tests/core/managers/gem_spec.lua b/tests/core/managers/gem_spec.lua
index beab3968..90d0c390 100644
--- a/tests/core/managers/gem_spec.lua
+++ b/tests/core/managers/gem_spec.lua
@@ -97,10 +97,11 @@ strscan (default: 3.0.1)
assert.spy(spawn.gem).was_called_with(match.tbl_containing {
"list",
cwd = "/tmp/install/dir",
- env = match.all_of(
- match.list_containing "GEM_HOME=/tmp/install/dir",
- match.list_containing "GEM_PATH=/tmp/install/dir"
- ),
+ env = match.tbl_containing {
+ GEM_HOME = "/tmp/install/dir",
+ GEM_PATH = "/tmp/install/dir",
+ PATH = match.matches "^/tmp/install/dir/bin:.*$",
+ },
})
assert.is_true(result:is_success())
assert.equals("0.44.0", result:get_or_nil())
@@ -139,10 +140,11 @@ solargraph (0.44.0 < 0.44.3)
assert.spy(spawn.gem).was_called_with(match.tbl_containing {
"outdated",
cwd = "/tmp/install/dir",
- env = match.all_of(
- match.list_containing "GEM_HOME=/tmp/install/dir",
- match.list_containing "GEM_PATH=/tmp/install/dir"
- ),
+ env = match.tbl_containing {
+ GEM_HOME = "/tmp/install/dir",
+ GEM_PATH = "/tmp/install/dir",
+ PATH = match.matches "^/tmp/install/dir/bin:.*$",
+ },
})
assert.is_true(result:is_success())
assert.equals(
diff --git a/tests/core/managers/git_spec.lua b/tests/core/managers/git_spec.lua
index b73760ee..25e58f6e 100644
--- a/tests/core/managers/git_spec.lua
+++ b/tests/core/managers/git_spec.lua
@@ -42,6 +42,7 @@ describe("git manager", function()
"clone",
"--depth",
"1",
+ vim.NIL,
"https://github.com/williamboman/nvim-lsp-installer.git",
".",
}
@@ -60,6 +61,7 @@ describe("git manager", function()
"clone",
"--depth",
"1",
+ vim.NIL,
"https://github.com/williamboman/nvim-lsp-installer.git",
".",
}
diff --git a/tests/core/managers/go_spec.lua b/tests/core/managers/go_spec.lua
index f299bf43..c7218335 100644
--- a/tests/core/managers/go_spec.lua
+++ b/tests/core/managers/go_spec.lua
@@ -1,4 +1,3 @@
-local match = require "luassert.match"
local mock = require "luassert.mock"
local stub = require "luassert.stub"
local spy = require "luassert.spy"
@@ -25,24 +24,24 @@ describe("go manager", function()
ctx.requested_version = Optional.of "42.13.37"
installer.run_installer(ctx, go.packages { "main-package", "supporting-package", "supporting-package2" })
assert.spy(ctx.spawn.go).was_called(3)
- assert.spy(ctx.spawn.go).was_called_with(match.tbl_containing {
+ assert.spy(ctx.spawn.go).was_called_with {
"install",
"-v",
"main-package@42.13.37",
- env = match.list_containing "GOBIN=/tmp/install-dir",
- })
- assert.spy(ctx.spawn.go).was_called_with(match.tbl_containing {
+ env = { GOBIN = "/tmp/install-dir" },
+ }
+ assert.spy(ctx.spawn.go).was_called_with {
"install",
"-v",
"supporting-package@latest",
- env = match.list_containing "GOBIN=/tmp/install-dir",
- })
- assert.spy(ctx.spawn.go).was_called_with(match.tbl_containing {
+ env = { GOBIN = "/tmp/install-dir" },
+ }
+ assert.spy(ctx.spawn.go).was_called_with {
"install",
"-v",
"supporting-package2@latest",
- env = match.list_containing "GOBIN=/tmp/install-dir",
- })
+ env = { GOBIN = "/tmp/install-dir" },
+ }
end)
)
diff --git a/tests/core/spawn_spec.lua b/tests/core/spawn_spec.lua
index eec14c30..d4716b61 100644
--- a/tests/core/spawn_spec.lua
+++ b/tests/core/spawn_spec.lua
@@ -9,7 +9,7 @@ describe("async spawn", function()
"should spawn commands and return stdout & stderr",
async_test(function()
local result = spawn.env {
- env = { "FOO=bar" },
+ env_raw = { "FOO=bar" },
}
assert.is_true(result:is_success())
assert.equals("FOO=bar\n", result:get_or_nil().stdout)
@@ -22,7 +22,7 @@ describe("async spawn", function()
async_test(function()
local stdio = process.in_memory_sink()
local result = spawn.env {
- env = { "FOO=bar" },
+ env_raw = { "FOO=bar" },
stdio_sink = stdio.sink,
}
assert.is_true(result:is_success())
@@ -39,7 +39,7 @@ describe("async spawn", function()
local result = spawn.bash {
"-c",
'echo "Hello $VAR"',
- env = { "VAR=world" },
+ env = { VAR = "world" },
}
assert.is_true(result:is_success())
@@ -54,12 +54,11 @@ describe("async spawn", function()
spy.on(process, "spawn")
local result = spawn.bash {
vim.NIL,
- spawn._when(true, "-c"),
- spawn._when(false, "shouldnotbeincluded"),
vim.NIL,
+ "-c",
{ vim.NIL, vim.NIL },
'echo "Hello $VAR"',
- env = { "VAR=world" },
+ env = { VAR = "world" },
}
assert.is_true(result:is_success())
@@ -73,7 +72,7 @@ describe("async spawn", function()
stdout = match.is_function(),
stderr = match.is_function(),
},
- env = match.tbl_containing { "VAR=world" },
+ env = match.list_containing "VAR=world",
args = match.tbl_containing {
"-c",
'echo "Hello $VAR"',
@@ -89,7 +88,7 @@ describe("async spawn", function()
async_test(function()
local result = spawn.bash {
{ "-c", 'echo "Hello $VAR"' },
- env = { "VAR=world" },
+ env = { VAR = "world" },
}
assert.is_true(result:is_success())