From ac9e5401dcc2d3242b61a7b12638c11080e37ea3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 1 Dec 2022 16:28:54 +0100 Subject: [PATCH] test: test XDG paths for tests and added a test that checks if they are setup correctly --- tests/core/init_spec.lua | 7 +++++++ tests/init.lua | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 tests/core/init_spec.lua diff --git a/tests/core/init_spec.lua b/tests/core/init_spec.lua new file mode 100644 index 0000000..3a1b4c7 --- /dev/null +++ b/tests/core/init_spec.lua @@ -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) diff --git a/tests/init.lua b/tests/init.lua index b5a94e8..a72b101 100644 --- a/tests/init.lua +++ b/tests/init.lua @@ -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()