test: test XDG paths for tests and added a test that checks if they are setup correctly

This commit is contained in:
Folke Lemaitre 2022-12-01 16:28:54 +01:00
parent d46bc7795c
commit ac9e5401dc
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 11 additions and 0 deletions

7
tests/core/init_spec.lua Normal file
View File

@ -0,0 +1,7 @@
describe("init", function()
it("has correct environment for tests", function()
for _, path in ipairs({ "config", "data", "cache", "state" }) do
assert(vim.fn.stdpath(path):find(".tests/" .. path))
end
end)
end)

View File

@ -27,6 +27,10 @@ function M.setup()
vim.opt.runtimepath:append(M.root())
vim.opt.packpath = { M.root(".tests/site") }
M.load("nvim-lua/plenary.nvim")
vim.env.XDG_CONFIG_HOME = M.root(".tests/config")
vim.env.XDG_DATA_HOME = M.root(".tests/data")
vim.env.XDG_STATE_HOME = M.root(".tests/state")
vim.env.XDG_CACHE_HOME = M.root(".tests/cache")
end
M.setup()