mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 10:35:08 +02:00
test: adapt recent changes in neovim and plenary (#4338)
This commit is contained in:
parent
76c839d734
commit
a587a45032
4 changed files with 25 additions and 24 deletions
|
@ -6,7 +6,7 @@ function M.search_file(file, args)
|
|||
local stdout, ret = Job:new({
|
||||
command = "grep",
|
||||
args = { args, file },
|
||||
cwd = get_cache_dir(),
|
||||
cwd = vim.loop.cwd(),
|
||||
on_stderr = function(_, data)
|
||||
table.insert(stderr, data)
|
||||
end,
|
||||
|
@ -14,20 +14,6 @@ function M.search_file(file, args)
|
|||
return ret, stdout, stderr
|
||||
end
|
||||
|
||||
function M.file_contains(file, query)
|
||||
local ret, stdout, stderr = M.search_file(file, query)
|
||||
if ret == 0 then
|
||||
return true
|
||||
end
|
||||
if not vim.tbl_isempty(stderr) then
|
||||
error(vim.inspect(stderr))
|
||||
end
|
||||
if not vim.tbl_isempty(stdout) then
|
||||
error(vim.inspect(stdout))
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function M.log_contains(query)
|
||||
local logfile = require("lvim.core.log"):get_path()
|
||||
local ret, stdout, stderr = M.search_file(logfile, query)
|
||||
|
|
|
@ -3,6 +3,22 @@ local uv = vim.loop
|
|||
local home_dir = uv.os_homedir()
|
||||
|
||||
a.describe("initial start", function()
|
||||
before_each(function()
|
||||
vim.cmd [[
|
||||
let v:errmsg = ""
|
||||
let v:errors = []
|
||||
]]
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
local errmsg = vim.fn.eval "v:errmsg"
|
||||
local exception = vim.fn.eval "v:exception"
|
||||
local errors = vim.fn.eval "v:errors"
|
||||
assert.equal("", errmsg)
|
||||
assert.equal("", exception)
|
||||
assert.True(vim.tbl_isempty(errors))
|
||||
end)
|
||||
|
||||
local lvim_config_path = get_config_dir()
|
||||
local lvim_runtime_path = get_runtime_dir()
|
||||
local lvim_cache_path = get_cache_dir()
|
||||
|
@ -33,7 +49,7 @@ a.describe("initial start", function()
|
|||
|
||||
a.it("should be able to pass basic checkhealth without errors", function()
|
||||
vim.cmd "set cmdheight&"
|
||||
vim.cmd "checkhealth nvim"
|
||||
vim.cmd "silent checkhealth nvim"
|
||||
local errmsg = vim.fn.eval "v:errmsg"
|
||||
local exception = vim.fn.eval "v:exception"
|
||||
assert.equal("", errmsg) -- v:errmsg was not updated.
|
||||
|
|
|
@ -47,9 +47,9 @@ a.describe("config-loader", function()
|
|||
config:load(user_config_path)
|
||||
assert.equal(vim.opt.undodir:get()[1], test_path)
|
||||
require("lvim.core.log"):set_level "error"
|
||||
os.execute(string.format("echo 'invalid_function()' >> %s", user_config_path))
|
||||
lvim.log.level = "error"
|
||||
os.execute(string.format("echo 'ignore_me()' >> %s", user_config_path))
|
||||
config:load(user_config_path)
|
||||
require("lvim.core.log"):set_level "error"
|
||||
assert.equal(vim.opt.undodir:get()[1], test_path)
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -45,11 +45,10 @@ a.describe("lsp workflow", function()
|
|||
a.it("should not include blacklisted servers in the generated templates", function()
|
||||
require("lvim.lsp").setup()
|
||||
|
||||
for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do
|
||||
for _, server_name in ipairs(lvim.lsp.automatic_configuration.skipped_servers) do
|
||||
local setup_cmd = string.format([[require("lvim.lsp.manager").setup(%q)]], server_name)
|
||||
assert.False(helpers.file_contains(file, setup_cmd))
|
||||
end
|
||||
local _, stdout, _ = helpers.search_file(lvim.lsp.templates_dir, setup_cmd)
|
||||
assert.True(vim.tbl_isempty(stdout))
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -81,7 +80,7 @@ a.describe("lsp workflow", function()
|
|||
local s = spy.on(require "lvim.lsp.templates", "generate_templates")
|
||||
|
||||
require("lvim.lsp").setup()
|
||||
assert.spy(s).was_not_called()
|
||||
assert.spy(s):was_not_called()
|
||||
s:revert()
|
||||
end)
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue