diff options
| author | William Boman <william@redwill.se> | 2022-04-06 11:35:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-06 11:35:35 +0200 |
| commit | 0795a757e8b78116f7e6d9e353bcb0443c7dbc52 (patch) | |
| tree | 76f8d5d5eb55bb438db0de84a741b2d6b81fe073 /tests/core | |
| parent | fix(pip3): always use normalized "python" executable with venv-enhanced path ... (diff) | |
| download | mason-0795a757e8b78116f7e6d9e353bcb0443c7dbc52.tar mason-0795a757e8b78116f7e6d9e353bcb0443c7dbc52.tar.gz mason-0795a757e8b78116f7e6d9e353bcb0443c7dbc52.tar.bz2 mason-0795a757e8b78116f7e6d9e353bcb0443c7dbc52.tar.lz mason-0795a757e8b78116f7e6d9e353bcb0443c7dbc52.tar.xz mason-0795a757e8b78116f7e6d9e353bcb0443c7dbc52.tar.zst mason-0795a757e8b78116f7e6d9e353bcb0443c7dbc52.zip | |
fix(r_language_server): run install script via stdin (#578)
Fixes #568.
Diffstat (limited to 'tests/core')
| -rw-r--r-- | tests/core/spawn_spec.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/core/spawn_spec.lua b/tests/core/spawn_spec.lua index 3bfafbc3..176135ee 100644 --- a/tests/core/spawn_spec.lua +++ b/tests/core/spawn_spec.lua @@ -1,3 +1,5 @@ +local spy = require "luassert.spy" +local match = require "luassert.match" local spawn = require "nvim-lsp-installer.core.spawn" local process = require "nvim-lsp-installer.process" @@ -76,4 +78,39 @@ describe("async spawn", function() assert.equals("", result:get_or_nil().stderr) end) ) + + it( + "should call on_spawn", + async_test(function() + local on_spawn = spy.new(function(_, stdio) + local stdin = stdio[1] + stdin:write "im so piped rn" + stdin:close() + end) + + local result = spawn.cat { + { "-" }, + on_spawn = on_spawn, + } + + assert.spy(on_spawn).was_called(1) + assert.spy(on_spawn).was_called_with(match.is_not.is_nil(), match.is_not.is_nil()) + assert.is_true(result:is_success()) + assert.equals("im so piped rn", result:get_or_nil().stdout) + end) + ) + + it( + "should not call on_spawn if spawning fails", + async_test(function() + local on_spawn = spy.new() + + local result = spawn.this_cmd_doesnt_exist { + on_spawn = on_spawn, + } + + assert.spy(on_spawn).was_called(0) + assert.is_true(result:is_failure()) + end) + ) end) |
