diff options
| author | William Boman <william@redwill.se> | 2023-09-11 00:05:44 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2025-02-16 09:32:29 +0100 |
| commit | 2275067747a118d6002f421cb54f28affbc0ef98 (patch) | |
| tree | 79bc1c2580ba96cc1b19e71f2b31f7c4c8ab490c /tests/mason-core/managers/gem_spec.lua | |
| parent | chore(main): release 1.11.0 (#1658) (diff) | |
| download | mason-2275067747a118d6002f421cb54f28affbc0ef98.tar mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.gz mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.bz2 mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.lz mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.xz mason-2275067747a118d6002f421cb54f28affbc0ef98.tar.zst mason-2275067747a118d6002f421cb54f28affbc0ef98.zip | |
refactor!: remove old managers (#1497)
Diffstat (limited to 'tests/mason-core/managers/gem_spec.lua')
| -rw-r--r-- | tests/mason-core/managers/gem_spec.lua | 190 |
1 files changed, 0 insertions, 190 deletions
diff --git a/tests/mason-core/managers/gem_spec.lua b/tests/mason-core/managers/gem_spec.lua deleted file mode 100644 index a99bf5e9..00000000 --- a/tests/mason-core/managers/gem_spec.lua +++ /dev/null @@ -1,190 +0,0 @@ -local Result = require "mason-core.result" -local _ = require "mason-core.functional" -local api = require "mason-registry.api" -local gem = require "mason-core.managers.gem" -local installer = require "mason-core.installer" -local match = require "luassert.match" -local mock = require "luassert.mock" -local spawn = require "mason-core.spawn" -local spy = require "luassert.spy" -local stub = require "luassert.stub" - -describe("gem manager", function() - it( - "should call gem install", - async_test(function() - local handle = InstallHandleGenerator "dummy" - local ctx = InstallContextGenerator(handle, { version = "42.13.37" }) - installer.prepare_installer(ctx):get_or_throw() - installer.exec_in_context(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", - "--no-user-install", - "--no-format-executable", - "--install-dir=.", - "--bindir=bin", - "--no-document", - match.tbl_containing { - "main-package:42.13.37", - "supporting-package", - "supporting-package2", - }, - }) - end) - ) - - it( - "should provide receipt information", - async_test(function() - local handle = InstallHandleGenerator "dummy" - local ctx = InstallContextGenerator(handle, { version = "42.13.37" }) - installer.prepare_installer(ctx):get_or_throw() - installer.exec_in_context(ctx, gem.packages { "main-package", "supporting-package", "supporting-package2" }) - assert.same({ - type = "gem", - package = "main-package", - }, ctx.receipt.primary_source) - assert.same({ - { - type = "gem", - package = "supporting-package", - }, - { - type = "gem", - package = "supporting-package2", - }, - }, ctx.receipt.secondary_sources) - end) - ) -end) - -describe("gem version check", function() - it( - "should return current version", - async_test(function() - stub(spawn, "gem") - spawn.gem.returns(Result.success { - stdout = _.dedent [[ - shellwords (default: 0.1.0) - singleton (default: 0.1.1) - solargraph (0.44.0) - stringio (default: 3.0.1) - strscan (default: 3.0.1) - ]], - }) - - local result = gem.get_installed_primary_package_version( - mock.new { - primary_source = mock.new { - type = "gem", - package = "solargraph", - }, - }, - "/tmp/install/dir" - ) - - assert.spy(spawn.gem).was_called(1) - assert.spy(spawn.gem).was_called_with(match.tbl_containing { - "list", - cwd = "/tmp/install/dir", - env = match.tbl_containing { - GEM_HOME = "/tmp/install/dir", - GEM_PATH = "/tmp/install/dir", - PATH = match.matches "^/tmp/install/dir/bin:.*$", - }, - }) - assert.is_true(result:is_success()) - assert.equals("0.44.0", result:get_or_nil()) - end) - ) - - it( - "should return outdated primary package", - async_test(function() - stub(spawn, "gem") - spawn.gem.returns(Result.success { - stdout = _.dedent [[ - shellwords (default: 0.1.0) - singleton (default: 0.1.1) - solargraph (0.44.0) - stringio (default: 3.0.1) - strscan (default: 3.0.1) - ]], - }) - stub(api, "get") - api.get.on_call_with("/api/rubygems/solargraph/versions/latest").returns(Result.success { - name = "solargraph", - version = "0.44.3", - }) - - local result = gem.check_outdated_primary_package( - mock.new { - primary_source = mock.new { - type = "gem", - package = "solargraph", - }, - }, - "/tmp/install/dir" - ) - - assert.is_true(result:is_success()) - assert.same({ - name = "solargraph", - current_version = "0.44.0", - latest_version = "0.44.3", - }, result:get_or_nil()) - end) - ) - - it( - "should return failure if primary package is not outdated", - async_test(function() - stub(spawn, "gem") - spawn.gem.returns(Result.success { - stdout = _.dedent [[ - shellwords (default: 0.1.0) - singleton (default: 0.1.1) - solargraph (0.44.0) - stringio (default: 3.0.1) - strscan (default: 3.0.1) - ]], - }) - stub(api, "get") - api.get.on_call_with("/api/rubygems/solargraph/versions/latest").returns(Result.success { - name = "solargraph", - version = "0.44.0", - }) - - local result = gem.check_outdated_primary_package( - mock.new { - primary_source = mock.new { - type = "gem", - package = "solargraph", - }, - }, - "/tmp/install/dir" - ) - - assert.is_true(result:is_failure()) - assert.equals("Primary package is not outdated.", result:err_or_nil()) - end) - ) - - it("should parse gem list output", function() - assert.same( - { - ["solargraph"] = "0.44.3", - ["unicode-display_width"] = "2.1.0", - }, - gem.parse_gem_list_output [[ - -*** LOCAL GEMS *** - -nokogiri (1.13.3 arm64-darwin) -solargraph (0.44.3) -unicode-display_width (2.1.0) -]] - ) - end) -end) |
