diff options
| author | kylo252 <[email protected]> | 2022-04-14 21:24:35 +0200 | 
|---|---|---|
| committer | kylo252 <[email protected]> | 2022-04-14 21:24:35 +0200 | 
| commit | 6d2e18295f510c2f2167bd911b0d421a3b7f112e (patch) | |
| tree | 453d5be502febdf596bf4b60b2d982b8b94db44a /tests | |
| parent | f92a0d610c1ee899ec8acb091130f2a5eec22812 (diff) | |
| parent | 09684eff642eb455bffda3100f29ef182f734a82 (diff) | |
Merge remote-tracking branch 'origin/rolling'
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/specs/config_loader_spec.lua | 20 | ||||
| -rw-r--r-- | tests/specs/lsp_spec.lua | 57 | ||||
| -rw-r--r-- | tests/specs/plugins_load_spec.lua | 6 | 
3 files changed, 51 insertions, 32 deletions
| diff --git a/tests/specs/config_loader_spec.lua b/tests/specs/config_loader_spec.lua index 1f2debc7..40eaa350 100644 --- a/tests/specs/config_loader_spec.lua +++ b/tests/specs/config_loader_spec.lua @@ -4,16 +4,28 @@ local config = require "lvim.config"  a.describe("config-loader", function()    local user_config_path = config:get_user_config_path() +  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) +    a.it("should be able to find user-config", function()      assert.equal(user_config_path, get_config_dir() .. "/config.lua")    end)    a.it("should be able to load user-config without errors", function()      config:load(user_config_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)    end)    a.it("should be able to reload user-config without errors", function() diff --git a/tests/specs/lsp_spec.lua b/tests/specs/lsp_spec.lua index 2518b237..7d9a3386 100644 --- a/tests/specs/lsp_spec.lua +++ b/tests/specs/lsp_spec.lua @@ -1,12 +1,26 @@  local a = require "plenary.async_lib.tests"  local utils = require "lvim.utils"  local helpers = require "tests.lvim.helpers" -local temp_dir = vim.loop.os_getenv "TEMP" or "/tmp" -lvim.lsp.templates_dir = join_paths(temp_dir, "lvim", "tests", "artifacts") +local spy = require "luassert.spy"  a.describe("lsp workflow", function() -  local Log = require "lvim.core.log" -  local logfile = Log:get_path() +  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")    a.it("should be able to delete ftplugin templates", function()      if utils.is_directory(lvim.lsp.templates_dir) then @@ -19,35 +33,13 @@ a.describe("lsp workflow", function()      if utils.is_directory(lvim.lsp.templates_dir) then        assert.equal(vim.fn.delete(lvim.lsp.templates_dir, "rf"), 0)      end -    require("lvim.lsp").setup() - -    -- we need to delay this check until the generation is completed -    vim.schedule(function() -      assert.True(utils.is_directory(lvim.lsp.templates_dir)) -    end) -  end) -  a.it("should not attempt to re-generate ftplugin templates", function() -    lvim.log.level = "debug" - -    local plugins = require "lvim.plugins" -    require("lvim.plugin-loader").load { plugins, lvim.plugins } - -    if utils.is_file(logfile) then -      assert.equal(vim.fn.delete(logfile), 0) -    end - -    assert.True(utils.is_directory(lvim.lsp.templates_dir))      require("lvim.lsp").setup() -    -- we need to delay this check until the log gets populated -    vim.schedule(function() -      assert.False(helpers.log_contains "templates") -    end) +    assert.True(utils.is_directory(lvim.lsp.templates_dir))    end)    a.it("should not include blacklisted servers in the generated templates", function() -    assert.True(utils.is_directory(lvim.lsp.templates_dir))      require("lvim.lsp").setup()      for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do @@ -59,7 +51,6 @@ a.describe("lsp workflow", function()    end)    a.it("should only include one server per generated template", function() -    assert.True(utils.is_directory(lvim.lsp.templates_dir))      require("lvim.lsp").setup()      for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do @@ -78,4 +69,14 @@ a.describe("lsp workflow", function()        assert.equal(err_msg, "")      end    end) + +  a.it("should not attempt to re-generate ftplugin templates", function() +    local s = spy.on(require "lvim.lsp.templates", "generate_templates") +    local plugins = require "lvim.plugins" +    require("lvim.plugin-loader").load { plugins, lvim.plugins } + +    require("lvim.lsp").setup() +    assert.spy(s).was_not_called() +    s:revert() +  end)  end) diff --git a/tests/specs/plugins_load_spec.lua b/tests/specs/plugins_load_spec.lua index d32c521d..1f11279e 100644 --- a/tests/specs/plugins_load_spec.lua +++ b/tests/specs/plugins_load_spec.lua @@ -4,6 +4,12 @@ a.describe("plugin-loader", function()    local plugins = require "lvim.plugins"    local loader = require "lvim.plugin-loader" +  pcall(function() +    lvim.log.level = "debug" +    package.loaded["packer.log"] = nil +    package.loaded["lvim.core.log"] = nil +  end) +    a.it("should be able to load default packages without errors", function()      loader.load { plugins, lvim.plugins } | 
