aboutsummaryrefslogtreecommitdiffstats
path: root/tests/setup/automatic_installation_exclude_spec.lua
blob: bfa5c81bc788b61c40bf5270bd1911bf0e490ad4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local spy = require "luassert.spy"
local lspconfig = require "lspconfig"
local configs = require "lspconfig.configs"
local servers = require "nvim-lsp-installer.servers"

describe("automatic_installation_exclude", function()
    it(
        "should install servers set up via lspconfig",
        async_test(function()
            local server1_installer_spy = spy.new()
            local server2_installer_spy = spy.new()
            local server1 = ServerGenerator {
                name = "automatic_installation_exclude1",
                installer = function()
                    server1_installer_spy()
                end,
            }
            local server2 = ServerGenerator {
                name = "automatic_installation_exclude2",
                installer = function()
                    server2_installer_spy()
                end,
            }

            servers.register(server1)
            servers.register(server2)

            configs[server1.name] = { default_config = {} }
            configs[server2.name] = { default_config = {} }

            require("nvim-lsp-installer").setup {
                automatic_installation = { exclude = { server2.name } },
            }

            lspconfig[server1.name].setup {}
            lspconfig[server2.name].setup {}

            assert.wait_for(function()
                assert.spy(server1_installer_spy).was_called(1)
                assert.spy(server2_installer_spy).was_called(0)
            end)
        end)
    )
end)