config_loader_spec.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. local a = require "plenary.async_lib.tests"
  2. local config = require "lvim.config"
  3. a.describe("config-loader", function()
  4. local user_config_path = config:get_user_config_path()
  5. a.it("should be able to find user-config", function()
  6. assert.equal(user_config_path, get_config_dir() .. "/config.lua")
  7. end)
  8. a.it("should be able to load user-config without errors", function()
  9. config:load(user_config_path)
  10. local errmsg = vim.fn.eval "v:errmsg"
  11. local exception = vim.fn.eval "v:exception"
  12. assert.equal("", errmsg) -- v:errmsg was not updated.
  13. assert.equal("", exception)
  14. end)
  15. a.it("should be able to reload user-config without errors", function()
  16. vim.opt.undodir = "/tmp"
  17. assert.equal(vim.opt.undodir:get()[1], "/tmp")
  18. config:reload()
  19. assert.equal(vim.opt.undodir:get()[1], get_cache_dir() .. "/undo")
  20. end)
  21. a.it("should not get interrupted by errors in user-config", function()
  22. vim.opt.undodir = "/tmp"
  23. assert.equal(vim.opt.undodir:get()[1], "/tmp")
  24. os.execute("echo bad_string_test >> " .. user_config_path)
  25. local error_handler = function(msg)
  26. return msg
  27. end
  28. local err = xpcall(config:reload(), error_handler)
  29. assert.falsy(err)
  30. assert.equal(vim.opt.undodir:get()[1], get_cache_dir() .. "/undo")
  31. end)
  32. end)