diff options
| author | William Boman <william@redwill.se> | 2022-03-06 21:48:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-06 21:48:29 +0100 |
| commit | dc39ce90f99a77699317bd31d95ce970690a4624 (patch) | |
| tree | 901e89bacca9b0d370c694fcd5a88cf2e1ae768e /tests/server_spec.lua | |
| parent | fix(fetch): shift args to put callback arg last (diff) | |
| download | mason-dc39ce90f99a77699317bd31d95ce970690a4624.tar mason-dc39ce90f99a77699317bd31d95ce970690a4624.tar.gz mason-dc39ce90f99a77699317bd31d95ce970690a4624.tar.bz2 mason-dc39ce90f99a77699317bd31d95ce970690a4624.tar.lz mason-dc39ce90f99a77699317bd31d95ce970690a4624.tar.xz mason-dc39ce90f99a77699317bd31d95ce970690a4624.tar.zst mason-dc39ce90f99a77699317bd31d95ce970690a4624.zip | |
run server installation in async execution context (#525)
Diffstat (limited to 'tests/server_spec.lua')
| -rw-r--r-- | tests/server_spec.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/server_spec.lua b/tests/server_spec.lua index 744b4cf8..81ae83b0 100644 --- a/tests/server_spec.lua +++ b/tests/server_spec.lua @@ -2,6 +2,13 @@ local spy = require "luassert.spy" local lsp_installer = require "nvim-lsp-installer" local server = require "nvim-lsp-installer.server" local a = require "nvim-lsp-installer.core.async" +local context = require "nvim-lsp-installer.installers.context" +local fs = require "nvim-lsp-installer.fs" + +local function timestamp() + local seconds, microseconds = vim.loop.gettimeofday() + return (seconds * 1000) + math.floor(microseconds / 1000) +end describe("server", function() it( @@ -47,4 +54,43 @@ describe("server", function() assert.is_false(srv:is_installed()) end) ) + + it( + "should remove directories upon installation failure", + async_test(function() + local srv = FailingServerGenerator { + name = "remove_dirs_failure", + root_dir = server.get_server_root_path "remove_dirs_failure", + installer = { + -- 1. sleep 500ms + function(_, callback) + vim.defer_fn(function() + callback(true) + end, 500) + end, + -- 2. promote install dir + context.promote_install_dir(), + -- 3. fail + function(_, callback) + callback(false) + end, + }, + } + srv:install() + + -- 1. installation started + a.sleep(50) + assert.is_true(fs.dir_exists(srv:get_tmp_install_dir())) + + -- 2. install dir promoted + a.sleep(500) + assert.is_false(fs.dir_exists(srv:get_tmp_install_dir())) + + -- 3. installation failed + a.sleep(200) + + assert.is_false(srv:is_installed()) + assert.is_false(fs.dir_exists(srv:get_tmp_install_dir())) + end) + ) end) |
