diff options
| author | William Boman <william@redwill.se> | 2022-04-06 00:25:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-06 00:25:50 +0200 |
| commit | 999476c324b26223aaf409a84497215e18d74499 (patch) | |
| tree | 323cc5b072471e5e78ee94b273157779bbcb9611 /tests/server_spec.lua | |
| parent | fix(taplo): use crate distribution (#576) (diff) | |
| download | mason-999476c324b26223aaf409a84497215e18d74499.tar mason-999476c324b26223aaf409a84497215e18d74499.tar.gz mason-999476c324b26223aaf409a84497215e18d74499.tar.bz2 mason-999476c324b26223aaf409a84497215e18d74499.tar.lz mason-999476c324b26223aaf409a84497215e18d74499.tar.xz mason-999476c324b26223aaf409a84497215e18d74499.tar.zst mason-999476c324b26223aaf409a84497215e18d74499.zip | |
switch majority of installers to async implementation (#574)
Diffstat (limited to 'tests/server_spec.lua')
| -rw-r--r-- | tests/server_spec.lua | 73 |
1 files changed, 17 insertions, 56 deletions
diff --git a/tests/server_spec.lua b/tests/server_spec.lua index 41a40750..d1ecbb6a 100644 --- a/tests/server_spec.lua +++ b/tests/server_spec.lua @@ -2,8 +2,6 @@ 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() @@ -55,64 +53,27 @@ describe("server", function() end) ) - -- it( - -- "should be able to run async installer functions", - -- async_test(function() - -- local srv = ServerGenerator { - -- name = "async_installer_fixture", - -- root_dir = server.get_server_root_path "async_installer_fixture", - -- async = true, - -- installer = function() - -- a.sleep(130) - -- end, - -- } - -- local start = timestamp() - -- srv:install() - -- a.sleep(100) - -- assert.wait_for(function() - -- assert.is_true(srv:is_installed()) - -- end) - -- local stop = timestamp() - -- assert.is_true(stop - start >= 100) - -- end) - -- ) - it( - "should remove directories upon installation failure", + "should be able to run sync installer functions", 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, - }, + local srv = ServerGenerator { + name = "async_installer_fixture", + root_dir = server.get_server_root_path "async_installer_fixture", + async = false, + installer = function(_, callback) + vim.defer_fn(function() + callback(true) + end, 130) + end, } + local start = timestamp() 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())) + a.sleep(100) + assert.wait_for(function() + assert.is_true(srv:is_installed()) + end) + local stop = timestamp() + assert.is_true(stop - start >= 100) end) ) end) |
