diff options
| author | William Boman <william@redwill.se> | 2022-04-11 01:04:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-11 01:04:06 +0200 |
| commit | 89abfcd2fbd56c3246772726a85ed0e548d77d3b (patch) | |
| tree | 5a90c3277ee853fe6c1c04be09982b94472f45ab /tests/core/managers | |
| parent | sumneko_lua: support Linux arm64 (#391) (diff) | |
| download | mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.gz mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.bz2 mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.lz mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.xz mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.zst mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.zip | |
make install context available via coroutine context (#586)
Diffstat (limited to 'tests/core/managers')
| -rw-r--r-- | tests/core/managers/cargo_spec.lua | 20 | ||||
| -rw-r--r-- | tests/core/managers/composer_spec.lua | 11 | ||||
| -rw-r--r-- | tests/core/managers/dotnet_spec.lua | 5 | ||||
| -rw-r--r-- | tests/core/managers/gem_spec.lua | 5 | ||||
| -rw-r--r-- | tests/core/managers/git_spec.lua | 17 | ||||
| -rw-r--r-- | tests/core/managers/go_spec.lua | 5 | ||||
| -rw-r--r-- | tests/core/managers/npm_spec.lua | 11 | ||||
| -rw-r--r-- | tests/core/managers/opam_spec.lua | 5 | ||||
| -rw-r--r-- | tests/core/managers/pip3_spec.lua | 11 |
9 files changed, 58 insertions, 32 deletions
diff --git a/tests/core/managers/cargo_spec.lua b/tests/core/managers/cargo_spec.lua index 303bf5d0..636a5f24 100644 --- a/tests/core/managers/cargo_spec.lua +++ b/tests/core/managers/cargo_spec.lua @@ -2,6 +2,7 @@ local spy = require "luassert.spy" local match = require "luassert.match" local mock = require "luassert.mock" local Optional = require "nvim-lsp-installer.core.optional" +local installer = require "nvim-lsp-installer.core.installer" local cargo = require "nvim-lsp-installer.core.managers.cargo" local Result = require "nvim-lsp-installer.core.result" local spawn = require "nvim-lsp-installer.core.spawn" @@ -21,7 +22,7 @@ describe("cargo manager", function() "should call cargo install", async_test(function() ctx.requested_version = Optional.of "42.13.37" - cargo.crate "my-crate"(ctx) + installer.run_installer(ctx, cargo.crate "my-crate") assert.spy(ctx.spawn.cargo).was_called(1) assert.spy(ctx.spawn.cargo).was_called_with { "install", @@ -38,7 +39,7 @@ describe("cargo manager", function() it( "should call cargo install with git source", async_test(function() - cargo.crate("https://my-crate.git", { git = true })(ctx) + installer.run_installer(ctx, cargo.crate("https://my-crate.git", { git = true })) assert.spy(ctx.spawn.cargo).was_called(1) assert.spy(ctx.spawn.cargo).was_called_with { "install", @@ -56,9 +57,7 @@ describe("cargo manager", function() "should respect options", async_test(function() ctx.requested_version = Optional.of "42.13.37" - cargo.crate("my-crate", { - features = "lsp", - })(ctx) + installer.run_installer(ctx, cargo.crate("my-crate", { features = "lsp" })) assert.spy(ctx.spawn.cargo).was_called(1) assert.spy(ctx.spawn.cargo).was_called_with { "install", @@ -77,9 +76,12 @@ describe("cargo manager", function() async_test(function() ctx.requested_version = Optional.of "42.13.37" local err = assert.has_error(function() - cargo.crate("my-crate", { - git = true, - })(ctx) + installer.run_installer( + ctx, + cargo.crate("my-crate", { + git = true, + }) + ) end) assert.equals("Providing a version when installing a git crate is not allowed.", err) assert.spy(ctx.spawn.cargo).was_called(0) @@ -89,7 +91,7 @@ describe("cargo manager", function() it( "should provide receipt information", async_test(function() - cargo.crate "main-package"(ctx) + installer.run_installer(ctx, cargo.crate "main-package") assert.equals( vim.inspect { type = "cargo", diff --git a/tests/core/managers/composer_spec.lua b/tests/core/managers/composer_spec.lua index caa0721e..e4365af0 100644 --- a/tests/core/managers/composer_spec.lua +++ b/tests/core/managers/composer_spec.lua @@ -1,5 +1,6 @@ local spy = require "luassert.spy" local mock = require "luassert.mock" +local installer = require "nvim-lsp-installer.core.installer" local Optional = require "nvim-lsp-installer.core.optional" local composer = require "nvim-lsp-installer.core.managers.composer" local Result = require "nvim-lsp-installer.core.result" @@ -21,7 +22,10 @@ describe("composer manager", function() async_test(function() ctx.fs.file_exists = mockx.returns(false) ctx.requested_version = Optional.of "42.13.37" - composer.require { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer( + ctx, + composer.packages { "main-package", "supporting-package", "supporting-package2" } + ) assert.spy(ctx.spawn.composer).was_called(2) assert.spy(ctx.spawn.composer).was_called_with { "init", @@ -43,7 +47,10 @@ describe("composer manager", function() "should provide receipt information", async_test(function() ctx.requested_version = Optional.of "42.13.37" - composer.require { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer( + ctx, + composer.packages { "main-package", "supporting-package", "supporting-package2" } + ) assert.equals( vim.inspect { type = "composer", diff --git a/tests/core/managers/dotnet_spec.lua b/tests/core/managers/dotnet_spec.lua index 4a6887da..8bc4bf06 100644 --- a/tests/core/managers/dotnet_spec.lua +++ b/tests/core/managers/dotnet_spec.lua @@ -1,5 +1,6 @@ local mock = require "luassert.mock" local Optional = require "nvim-lsp-installer.core.optional" +local installer = require "nvim-lsp-installer.core.installer" local dotnet = require "nvim-lsp-installer.core.managers.dotnet" describe("dotnet manager", function() @@ -17,7 +18,7 @@ describe("dotnet manager", function() "should call dotnet tool update", async_test(function() ctx.requested_version = Optional.of "42.13.37" - dotnet.package "main-package"(ctx) + installer.run_installer(ctx, dotnet.package "main-package") assert.spy(ctx.spawn.dotnet).was_called(1) assert.spy(ctx.spawn.dotnet).was_called_with { "tool", @@ -34,7 +35,7 @@ describe("dotnet manager", function() "should provide receipt information", async_test(function() ctx.requested_version = Optional.of "42.13.37" - dotnet.package "main-package"(ctx) + installer.run_installer(ctx, dotnet.package "main-package") assert.equals( vim.inspect { type = "dotnet", diff --git a/tests/core/managers/gem_spec.lua b/tests/core/managers/gem_spec.lua index e258c65b..beab3968 100644 --- a/tests/core/managers/gem_spec.lua +++ b/tests/core/managers/gem_spec.lua @@ -1,6 +1,7 @@ local spy = require "luassert.spy" local match = require "luassert.match" local mock = require "luassert.mock" +local installer = require "nvim-lsp-installer.core.installer" local Optional = require "nvim-lsp-installer.core.optional" local gem = require "nvim-lsp-installer.core.managers.gem" local Result = require "nvim-lsp-installer.core.result" @@ -21,7 +22,7 @@ describe("gem manager", function() "should call gem install", async_test(function() ctx.requested_version = Optional.of "42.13.37" - gem.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, gem.packages { "main-package", "supporting-package", "supporting-package2" }) assert.spy(ctx.spawn.gem).was_called(1) assert.spy(ctx.spawn.gem).was_called_with(match.tbl_containing { "install", @@ -42,7 +43,7 @@ describe("gem manager", function() "should provide receipt information", async_test(function() ctx.requested_version = Optional.of "42.13.37" - gem.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, gem.packages { "main-package", "supporting-package", "supporting-package2" }) assert.equals( vim.inspect { type = "gem", diff --git a/tests/core/managers/git_spec.lua b/tests/core/managers/git_spec.lua index 2f6c6ace..b73760ee 100644 --- a/tests/core/managers/git_spec.lua +++ b/tests/core/managers/git_spec.lua @@ -2,6 +2,7 @@ local spy = require "luassert.spy" local mock = require "luassert.mock" local spawn = require "nvim-lsp-installer.core.spawn" local Result = require "nvim-lsp-installer.core.result" +local installer = require "nvim-lsp-installer.core.installer" local git = require "nvim-lsp-installer.core.managers.git" local Optional = require "nvim-lsp-installer.core.optional" @@ -21,7 +22,9 @@ describe("git manager", function() "should fail if no git repo provided", async_test(function() local err = assert.has_errors(function() - git.clone {}(ctx) + installer.run_installer(ctx, function() + git.clone {} + end) end) assert.equals("No git URL provided.", err) assert.spy(ctx.spawn.git).was_not_called() @@ -31,7 +34,9 @@ describe("git manager", function() it( "should clone provided repo", async_test(function() - git.clone { "https://github.com/williamboman/nvim-lsp-installer.git" }(ctx) + installer.run_installer(ctx, function() + git.clone { "https://github.com/williamboman/nvim-lsp-installer.git" } + end) assert.spy(ctx.spawn.git).was_called(1) assert.spy(ctx.spawn.git).was_called_with { "clone", @@ -47,7 +52,9 @@ describe("git manager", function() "should fetch and checkout revision if requested", async_test(function() ctx.requested_version = Optional.of "1337" - git.clone { "https://github.com/williamboman/nvim-lsp-installer.git" }(ctx) + installer.run_installer(ctx, function() + git.clone { "https://github.com/williamboman/nvim-lsp-installer.git" } + end) assert.spy(ctx.spawn.git).was_called(3) assert.spy(ctx.spawn.git).was_called_with { "clone", @@ -70,7 +77,9 @@ describe("git manager", function() it( "should provide receipt information", async_test(function() - git.clone { "https://github.com/williamboman/nvim-lsp-installer.git" }(ctx) + installer.run_installer(ctx, function() + git.clone({ "https://github.com/williamboman/nvim-lsp-installer.git" }).with_receipt() + end) assert.equals( vim.inspect { type = "git", diff --git a/tests/core/managers/go_spec.lua b/tests/core/managers/go_spec.lua index 4152d671..f299bf43 100644 --- a/tests/core/managers/go_spec.lua +++ b/tests/core/managers/go_spec.lua @@ -6,6 +6,7 @@ local Optional = require "nvim-lsp-installer.core.optional" local Result = require "nvim-lsp-installer.core.result" local go = require "nvim-lsp-installer.core.managers.go" local spawn = require "nvim-lsp-installer.core.spawn" +local installer = require "nvim-lsp-installer.core.installer" describe("go manager", function() ---@type InstallContext @@ -22,7 +23,7 @@ describe("go manager", function() "should call go install", async_test(function() ctx.requested_version = Optional.of "42.13.37" - go.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, go.packages { "main-package", "supporting-package", "supporting-package2" }) assert.spy(ctx.spawn.go).was_called(3) assert.spy(ctx.spawn.go).was_called_with(match.tbl_containing { "install", @@ -49,7 +50,7 @@ describe("go manager", function() "should provide receipt information", async_test(function() ctx.requested_version = Optional.of "42.13.37" - go.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, go.packages { "main-package", "supporting-package", "supporting-package2" }) assert.equals( vim.inspect { type = "go", diff --git a/tests/core/managers/npm_spec.lua b/tests/core/managers/npm_spec.lua index c5e2b2b9..2d804572 100644 --- a/tests/core/managers/npm_spec.lua +++ b/tests/core/managers/npm_spec.lua @@ -2,6 +2,7 @@ local spy = require "luassert.spy" local match = require "luassert.match" local mock = require "luassert.mock" local Optional = require "nvim-lsp-installer.core.optional" +local installer = require "nvim-lsp-installer.core.installer" local npm = require "nvim-lsp-installer.core.managers.npm" local Result = require "nvim-lsp-installer.core.result" local spawn = require "nvim-lsp-installer.core.spawn" @@ -21,7 +22,7 @@ describe("npm manager", function() "should call npm install", async_test(function() ctx.requested_version = Optional.of "42.13.37" - npm.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, npm.packages { "main-package", "supporting-package", "supporting-package2" }) assert.spy(ctx.spawn.npm).was_called(1) assert.spy(ctx.spawn.npm).was_called_with(match.tbl_containing { "install", @@ -39,7 +40,9 @@ describe("npm manager", function() async_test(function() ctx.fs.file_exists = mockx.returns(false) ctx.fs.dir_exists = mockx.returns(false) - npm.install { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, function() + npm.install { "main-package", "supporting-package", "supporting-package2" } + end) assert.spy(ctx.spawn.npm).was_called_with { "init", "--yes", @@ -52,7 +55,7 @@ describe("npm manager", function() "should append .npmrc file", async_test(function() ctx.requested_version = Optional.of "42.13.37" - npm.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, npm.packages { "main-package", "supporting-package", "supporting-package2" }) assert.spy(ctx.fs.append_file).was_called(1) assert.spy(ctx.fs.append_file).was_called_with(ctx.fs, ".npmrc", "global-style=true") end) @@ -62,7 +65,7 @@ describe("npm manager", function() "should provide receipt information", async_test(function() ctx.requested_version = Optional.of "42.13.37" - npm.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, npm.packages { "main-package", "supporting-package", "supporting-package2" }) assert.equals( vim.inspect { type = "npm", diff --git a/tests/core/managers/opam_spec.lua b/tests/core/managers/opam_spec.lua index 0ec003ec..39e892ca 100644 --- a/tests/core/managers/opam_spec.lua +++ b/tests/core/managers/opam_spec.lua @@ -1,6 +1,7 @@ local match = require "luassert.match" local mock = require "luassert.mock" local Optional = require "nvim-lsp-installer.core.optional" +local installer = require "nvim-lsp-installer.core.installer" local opam = require "nvim-lsp-installer.core.managers.opam" describe("opam manager", function() @@ -18,7 +19,7 @@ describe("opam manager", function() "should call opam install", async_test(function() ctx.requested_version = Optional.of "42.13.37" - opam.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, opam.packages { "main-package", "supporting-package", "supporting-package2" }) assert.spy(ctx.spawn.opam).was_called(1) assert.spy(ctx.spawn.opam).was_called_with(match.tbl_containing { "install", @@ -38,7 +39,7 @@ describe("opam manager", function() "should provide receipt information", async_test(function() ctx.requested_version = Optional.of "42.13.37" - opam.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, opam.packages { "main-package", "supporting-package", "supporting-package2" }) assert.equals( vim.inspect { type = "opam", diff --git a/tests/core/managers/pip3_spec.lua b/tests/core/managers/pip3_spec.lua index d72914e7..344c177c 100644 --- a/tests/core/managers/pip3_spec.lua +++ b/tests/core/managers/pip3_spec.lua @@ -4,6 +4,7 @@ local match = require "luassert.match" local pip3 = require "nvim-lsp-installer.core.managers.pip3" local Optional = require "nvim-lsp-installer.core.optional" +local installer = require "nvim-lsp-installer.core.installer" local Result = require "nvim-lsp-installer.core.result" local settings = require "nvim-lsp-installer.settings" local spawn = require "nvim-lsp-installer.core.spawn" @@ -31,7 +32,7 @@ describe("pip3 manager", function() "should create venv and call pip3 install", async_test(function() ctx.requested_version = Optional.of "42.13.37" - pip3.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, pip3.packages { "main-package", "supporting-package", "supporting-package2" }) assert.spy(ctx.promote_cwd).was_called(1) assert.spy(ctx.spawn.python3).was_called(1) assert.spy(ctx.spawn.python3).was_called_with { @@ -66,7 +67,7 @@ describe("pip3 manager", function() [vim.g.python3_host_prog] = mockx.throws(), } local err = assert.has_error(function() - pip3.packages { "package" }(ctx) + installer.run_installer(ctx, pip3.packages { "package" }) end) vim.g.python3_host_prog = nil @@ -86,7 +87,7 @@ describe("pip3 manager", function() python = mockx.returns {}, [vim.g.python3_host_prog] = mockx.returns {}, } - pip3.packages { "package" }(ctx) + installer.run_installer(ctx, pip3.packages { "package" }) vim.g.python3_host_prog = nil assert.spy(ctx.spawn.python3).was_called(0) assert.spy(ctx.spawn.python).was_called(1) @@ -102,7 +103,7 @@ describe("pip3 manager", function() install_args = { "--proxy", "http://localhost:8080" }, }, } - pip3.packages { "package" }(ctx) + installer.run_installer(ctx, pip3.packages { "package" }) settings.set(settings._DEFAULT_SETTINGS) assert.spy(ctx.spawn.python).was_called_with(match.tbl_containing { "-m", @@ -120,7 +121,7 @@ describe("pip3 manager", function() "should provide receipt information", async_test(function() ctx.requested_version = Optional.of "42.13.37" - pip3.packages { "main-package", "supporting-package", "supporting-package2" }(ctx) + installer.run_installer(ctx, pip3.packages { "main-package", "supporting-package", "supporting-package2" }) assert.equals( vim.inspect { type = "pip3", |
