summaryrefslogtreecommitdiff
path: root/mac/.config/LunarVim/tests/specs
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
commit07d294425a98ee5d1e22d03e2b24ae2c76e487c0 (patch)
treea6818f0d64438c5fdb88b00a35d944f80c056213 /mac/.config/LunarVim/tests/specs
parent6fc28cdb3529ca8ee864cb5c41674cb0a4af72a1 (diff)
updates
Diffstat (limited to 'mac/.config/LunarVim/tests/specs')
-rw-r--r--mac/.config/LunarVim/tests/specs/bootstrap_spec.lua57
-rw-r--r--mac/.config/LunarVim/tests/specs/config_loader_spec.lua54
-rw-r--r--mac/.config/LunarVim/tests/specs/lsp_spec.lua94
-rw-r--r--mac/.config/LunarVim/tests/specs/plugins_load_spec.lua37
4 files changed, 242 insertions, 0 deletions
diff --git a/mac/.config/LunarVim/tests/specs/bootstrap_spec.lua b/mac/.config/LunarVim/tests/specs/bootstrap_spec.lua
new file mode 100644
index 0000000..bb52955
--- /dev/null
+++ b/mac/.config/LunarVim/tests/specs/bootstrap_spec.lua
@@ -0,0 +1,57 @@
+local uv = vim.loop
+local home_dir = uv.os_homedir()
+
+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()
+
+ it("should be able to detect test environment", function()
+ assert.truthy(os.getenv "LVIM_TEST_ENV")
+ assert.falsy(package.loaded["lvim.impatient"])
+ end)
+
+ it("should be able to use lunarvim cache directory using vim.fn", function()
+ assert.equal(lvim_cache_path, vim.fn.stdpath "cache")
+ end)
+
+ it("should be to retrieve default neovim directories", function()
+ local xdg_config = os.getenv "XDG_CONFIG_HOME" or join_paths(home_dir, ".config")
+ assert.equal(join_paths(xdg_config, "nvim"), vim.call("stdpath", "config"))
+ end)
+
+ it("should be able to read lunarvim directories", function()
+ local rtp_list = vim.opt.rtp:get()
+ assert.truthy(vim.tbl_contains(rtp_list, lvim_runtime_path .. "/lvim"))
+ assert.truthy(vim.tbl_contains(rtp_list, lvim_config_path))
+ end)
+
+ it("should be able to run treesitter without errors", function()
+ assert.truthy(vim.treesitter.highlighter.active)
+ end)
+
+ it("should be able to pass basic checkhealth without errors", function()
+ vim.cmd "set cmdheight&"
+ 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.
+ assert.equal("", exception)
+ end)
+end)
diff --git a/mac/.config/LunarVim/tests/specs/config_loader_spec.lua b/mac/.config/LunarVim/tests/specs/config_loader_spec.lua
new file mode 100644
index 0000000..565f1a5
--- /dev/null
+++ b/mac/.config/LunarVim/tests/specs/config_loader_spec.lua
@@ -0,0 +1,54 @@
+local config = require "lvim.config"
+local fmt = string.format
+
+describe("config-loader", function()
+ 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 = []
+ ]]
+ 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)
+
+ it("should be able to find user-config", function()
+ assert.equal(user_config_path, get_config_dir() .. "/config.lua")
+ end)
+
+ it("should be able to load user-config without errors", function()
+ config:load(user_config_path)
+ end)
+
+ it("should be able to reload user-config without errors", function()
+ config:load(user_config_path)
+ local test_path = "/tmp/lvim"
+ 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)
+ end)
+
+ 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:load(user_config_path)
+ assert.equal(vim.opt.undodir:get()[1], test_path)
+ require("lvim.core.log"):set_level "error"
+ lvim.log.level = "error"
+ os.execute(string.format("echo 'ignore_me()' >> %s", user_config_path))
+ config:load(user_config_path)
+ assert.equal(vim.opt.undodir:get()[1], test_path)
+ end)
+end)
diff --git a/mac/.config/LunarVim/tests/specs/lsp_spec.lua b/mac/.config/LunarVim/tests/specs/lsp_spec.lua
new file mode 100644
index 0000000..3f81405
--- /dev/null
+++ b/mac/.config/LunarVim/tests/specs/lsp_spec.lua
@@ -0,0 +1,94 @@
+local utils = require "lvim.utils"
+local helpers = require "tests.lvim.helpers"
+local spy = require "luassert.spy"
+
+describe("lsp workflow", 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)
+
+ lvim.lsp.templates_dir = join_paths(get_cache_dir(), "artifacts")
+ vim.go.loadplugins = true
+ local plugins = require "lvim.plugins"
+ require("lvim.plugin-loader").load { plugins, lvim.plugins }
+
+ -- trigger loading event manually for mason
+ vim.api.nvim_exec_autocmds("User", { pattern = "FileOpened" })
+
+ it("should be able to delete ftplugin templates", function()
+ if utils.is_directory(lvim.lsp.templates_dir) then
+ vim.fn.delete(lvim.lsp.templates_dir, "rf")
+ vim.wait(100)
+ end
+ assert.False(utils.is_directory(lvim.lsp.templates_dir))
+ end)
+
+ it("should be able to generate ftplugin templates", function()
+ if utils.is_directory(lvim.lsp.templates_dir) then
+ vim.fn.delete(lvim.lsp.templates_dir, "rf")
+ vim.wait(100)
+ end
+
+ require("lvim.lsp").setup()
+ vim.wait(500)
+
+ local template_files = vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)
+ assert.False(vim.tbl_isempty(template_files))
+ end)
+
+ it("should not include blacklisted servers in the generated templates", function()
+ require("lvim.lsp").setup()
+
+ 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)
+ local _, stdout, _ = helpers.search_file(lvim.lsp.templates_dir, setup_cmd)
+ assert.True(vim.tbl_isempty(stdout))
+ end
+ end)
+
+ it("should only include one server per generated template", function()
+ require("lvim.lsp").setup()
+ vim.wait(500)
+
+ local allowed_dupes = { "tailwindcss", "ruff" }
+ local template_files = vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)
+ for _, file in ipairs(template_files) do
+ local content = {}
+ for entry in io.lines(file) do
+ local server_name = entry:match [[.*setup%("(.*)"%)]]
+ if not vim.tbl_contains(allowed_dupes, server_name) then
+ table.insert(content, server_name)
+ end
+ end
+ local err_msg = ""
+ if #content > 1 then
+ err_msg = string.format(
+ "found more than one server for [%q]: \n{\n %q \n}",
+ file:match "[^/]*.lua$",
+ table.concat(content, ", ")
+ )
+ end
+ assert.equal(err_msg, "")
+ end
+ end)
+
+ it("should not attempt to re-generate ftplugin templates", function()
+ local s = spy.on(require "lvim.lsp.templates", "generate_templates")
+
+ require("lvim.lsp").setup()
+ assert.spy(s):was_not_called()
+ s:revert()
+ end)
+end)
diff --git a/mac/.config/LunarVim/tests/specs/plugins_load_spec.lua b/mac/.config/LunarVim/tests/specs/plugins_load_spec.lua
new file mode 100644
index 0000000..94896d2
--- /dev/null
+++ b/mac/.config/LunarVim/tests/specs/plugins_load_spec.lua
@@ -0,0 +1,37 @@
+describe("plugin-loader", function()
+ local plugins = require "lvim.plugins"
+ local loader = require "lvim.plugin-loader"
+
+ pcall(function()
+ lvim.log.level = "debug"
+ package.loaded["lvim.core.log"] = nil
+ end)
+
+ it("should be able to load default packages without errors", function()
+ vim.go.loadplugins = true
+ loader.load { plugins, lvim.plugins }
+
+ -- TODO: maybe there's a way to avoid hard-coding the names of the modules?
+ local startup_plugins = {
+ "lazy",
+ }
+
+ for _, plugin in ipairs(startup_plugins) do
+ assert.truthy(package.loaded[plugin])
+ end
+ end)
+
+ it("should be able to load lsp packages without errors", function()
+ require("lvim.lsp").setup()
+
+ local lsp_packages = {
+ "lspconfig",
+ "nlspsettings",
+ "null-ls",
+ }
+
+ for _, plugin in ipairs(lsp_packages) do
+ assert.truthy(package.loaded[plugin])
+ end
+ end)
+end)