summaryrefslogtreecommitdiff
path: root/tests/specs/config_loader_spec.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2022-05-21 16:48:47 +0200
committerGitHub <[email protected]>2022-05-21 16:48:47 +0200
commit23df368b00bda0ed4a01fac92f7ad80998c1d34a (patch)
tree2362ff18ac68eab313380e814238fa15c1237934 /tests/specs/config_loader_spec.lua
parenta2454310b6c0b5b530521a77b9b8eb290274e040 (diff)
refactor: load the default options once (#2592)
BREAKING CHANGE: modifying the default options for keymaps and autocmds is now done by overwriting them, since they won't be loaded into the global `lvim` table anymore * refactor: use the lua-commands api * refactor!: use the lua-autocmds api * fix(settings): let neovim handle spellfile * feat: add log:set_log_level() * chore: update examples * chore: add deprecation notice for custom_groups
Diffstat (limited to 'tests/specs/config_loader_spec.lua')
-rw-r--r--tests/specs/config_loader_spec.lua30
1 files changed, 11 insertions, 19 deletions
diff --git a/tests/specs/config_loader_spec.lua b/tests/specs/config_loader_spec.lua
index 40eaa350..99053548 100644
--- a/tests/specs/config_loader_spec.lua
+++ b/tests/specs/config_loader_spec.lua
@@ -1,10 +1,13 @@
local a = require "plenary.async_lib.tests"
local config = require "lvim.config"
+local fmt = string.format
a.describe("config-loader", function()
- local user_config_path = config:get_user_config_path()
+ local user_config_path = join_paths(get_config_dir(), "config.lua")
+ local default_config_path = join_paths(get_lvim_base_dir(), "utils", "installer", "config.example.lua")
before_each(function()
+ os.execute(fmt("cp -f %s %s", default_config_path, user_config_path))
vim.cmd [[
let v:errmsg = ""
let v:errors = []
@@ -41,23 +44,12 @@ a.describe("config-loader", function()
a.it("should not get interrupted by errors in user-config", function()
local test_path = "/tmp/lunarvim"
os.execute(string.format([[echo "vim.opt.undodir = '%s'" >> %s]], test_path, user_config_path))
- config:reload()
- vim.schedule(function()
- assert.equal(vim.opt.undodir:get()[1], test_path)
- end)
- os.execute(string.format("echo 'bad_string_test' >> %s", user_config_path))
- local error_handler = function(msg)
- return msg
- end
- local err = xpcall(config:reload(), error_handler)
- assert.falsy(err)
- vim.schedule(function()
- assert.equal(vim.opt.undodir:get()[1], test_path)
- local errmsg = vim.fn.eval "v:errmsg"
- local exception = vim.fn.eval "v:exception"
- assert.equal("", errmsg) -- v:errmsg was not updated.
- assert.equal("", exception)
- os.execute(string.format("echo '' > %s", user_config_path))
- end)
+ 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))
+ config:load(user_config_path)
+ require("lvim.core.log"):set_level "error"
+ assert.equal(vim.opt.undodir:get()[1], test_path)
end)
end)