diff options
| author | William Boman <william@redwill.se> | 2025-05-02 03:52:10 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2025-05-02 03:57:07 +0200 |
| commit | 4da89f3ab04783da990f9bd40aaa36c22e59375b (patch) | |
| tree | bb672a1bd796a6adf3d04473cb66a3e90be00707 /tests | |
| parent | feat(ui): display purl information (diff) | |
| download | mason-4da89f3ab04783da990f9bd40aaa36c22e59375b.tar mason-4da89f3ab04783da990f9bd40aaa36c22e59375b.tar.gz mason-4da89f3ab04783da990f9bd40aaa36c22e59375b.tar.bz2 mason-4da89f3ab04783da990f9bd40aaa36c22e59375b.tar.lz mason-4da89f3ab04783da990f9bd40aaa36c22e59375b.tar.xz mason-4da89f3ab04783da990f9bd40aaa36c22e59375b.tar.zst mason-4da89f3ab04783da990f9bd40aaa36c22e59375b.zip | |
refactor(registry): change lua registries to not instantiate Package themselves
Instead of having Lua registries instantiate package instances
themselves we now do it in the installer of Lua registry sources.
This aligns the behaviour of the Lua registry protocol with the other
registry protocols.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/helpers/lua/dummy-registry/dummy.lua (renamed from tests/helpers/lua/dummy-registry/dummy_package.lua) | 11 | ||||
| -rw-r--r-- | tests/helpers/lua/dummy-registry/dummy2.lua (renamed from tests/helpers/lua/dummy-registry/dummy2_package.lua) | 11 | ||||
| -rw-r--r-- | tests/helpers/lua/dummy-registry/index.lua | 6 | ||||
| -rw-r--r-- | tests/helpers/lua/dummy-registry/registry.lua (renamed from tests/helpers/lua/dummy-registry/registry_package.lua) | 5 | ||||
| -rw-r--r-- | tests/mason-core/installer/context_spec.lua | 5 | ||||
| -rw-r--r-- | tests/mason-core/installer/linker_spec.lua | 4 | ||||
| -rw-r--r-- | tests/mason-core/package/package_spec.lua | 4 | ||||
| -rw-r--r-- | tests/mason-registry/sources/lua_spec.lua | 27 | ||||
| -rw-r--r-- | tests/minimal_init.vim | 2 |
9 files changed, 26 insertions, 49 deletions
diff --git a/tests/helpers/lua/dummy-registry/dummy_package.lua b/tests/helpers/lua/dummy-registry/dummy.lua index 4fbaf44d..4b06f4d1 100644 --- a/tests/helpers/lua/dummy-registry/dummy_package.lua +++ b/tests/helpers/lua/dummy-registry/dummy.lua @@ -1,13 +1,10 @@ -local Pkg = require "mason-core.package" - -return Pkg:new { - schema = "registry+v1", +return { name = "dummy", description = [[This is a dummy package.]], homepage = "https://example.com", - licenses = { Pkg.License.MIT }, - languages = { Pkg.Lang.DummyLang }, - categories = { Pkg.Cat.LSP }, + licenses = { "MIT" }, + languages = { "DummyLang" }, + categories = { "LSP" }, source = { id = "pkg:mason/dummy@1.0.0", ---@async diff --git a/tests/helpers/lua/dummy-registry/dummy2_package.lua b/tests/helpers/lua/dummy-registry/dummy2.lua index 008d27b2..8dc26c9f 100644 --- a/tests/helpers/lua/dummy-registry/dummy2_package.lua +++ b/tests/helpers/lua/dummy-registry/dummy2.lua @@ -1,13 +1,10 @@ -local Pkg = require "mason-core.package" - -return Pkg:new { - schema = "registry+v1", +return { name = "dummy2", description = [[This is a dummy2 package.]], homepage = "https://example.com", - licenses = { Pkg.License.MIT }, - languages = { Pkg.Lang.Dummy2Lang }, - categories = { Pkg.Cat.LSP }, + licenses = { "MIT" }, + languages = { "Dummy2Lang" }, + categories = { "LSP" }, source = { id = "pkg:mason/dummy2@1.0.0", ---@async diff --git a/tests/helpers/lua/dummy-registry/index.lua b/tests/helpers/lua/dummy-registry/index.lua index 85fe000f..112a2df2 100644 --- a/tests/helpers/lua/dummy-registry/index.lua +++ b/tests/helpers/lua/dummy-registry/index.lua @@ -1,5 +1,5 @@ return { - ["dummy"] = "dummy-registry.dummy_package", - ["dummy2"] = "dummy-registry.dummy2_package", - ["registry"] = "dummy-registry.registry_package", + ["dummy"] = "dummy-registry.dummy", + ["dummy2"] = "dummy-registry.dummy2", + ["registry"] = "dummy-registry.registry", } diff --git a/tests/helpers/lua/dummy-registry/registry_package.lua b/tests/helpers/lua/dummy-registry/registry.lua index 7e5d9fbd..3cc4858b 100644 --- a/tests/helpers/lua/dummy-registry/registry_package.lua +++ b/tests/helpers/lua/dummy-registry/registry.lua @@ -1,7 +1,4 @@ -local Pkg = require "mason-core.package" - -return Pkg:new { - schema = "registry+v1", +return { name = "registry", description = [[This is a dummy package.]], homepage = "https://example.com", diff --git a/tests/mason-core/installer/context_spec.lua b/tests/mason-core/installer/context_spec.lua index ad469e08..92ef1c49 100644 --- a/tests/mason-core/installer/context_spec.lua +++ b/tests/mason-core/installer/context_spec.lua @@ -94,7 +94,6 @@ cmd.exe /C echo %GREETING% %*]] it("should write Node exec wrapper", function() local js_rel_path = path.concat { "some", "obscure", "path", "server.js" } - local dummy = registry.get_package "dummy" local ctx = test_helpers.create_context() stub(ctx, "write_shell_exec_wrapper") stub(ctx.fs, "file_exists") @@ -112,7 +111,6 @@ cmd.exe /C echo %GREETING% %*]] it("should write Ruby exec wrapper", function() local js_rel_path = path.concat { "some", "obscure", "path", "server.js" } - local dummy = registry.get_package "dummy" local ctx = test_helpers.create_context() stub(ctx, "write_shell_exec_wrapper") stub(ctx.fs, "file_exists") @@ -147,7 +145,6 @@ cmd.exe /C echo %GREETING% %*]] end) it("should write Python exec wrapper", function() - local dummy = registry.get_package "dummy" local ctx = test_helpers.create_context() stub(ctx.cwd, "get") ctx.cwd.get.returns "/tmp/placeholder" @@ -183,7 +180,6 @@ cmd.exe /C echo %GREETING% %*]] end) it("should write exec wrapper", function() - local dummy = registry.get_package "dummy" local exec_rel_path = path.concat { "obscure", "path", "to", "server" } local ctx = test_helpers.create_context() stub(ctx, "write_shell_exec_wrapper") @@ -219,7 +215,6 @@ cmd.exe /C echo %GREETING% %*]] it("should write PHP exec wrapper", function() local php_rel_path = path.concat { "some", "obscure", "path", "cli.php" } - local dummy = registry.get_package "dummy" local ctx = test_helpers.create_context() stub(ctx, "write_shell_exec_wrapper") stub(ctx.fs, "file_exists") diff --git a/tests/mason-core/installer/linker_spec.lua b/tests/mason-core/installer/linker_spec.lua index 2177f6a3..6bf63a14 100644 --- a/tests/mason-core/installer/linker_spec.lua +++ b/tests/mason-core/installer/linker_spec.lua @@ -40,7 +40,6 @@ describe("linker", function() end) it("should symlink executable on Unix", function() - local dummy = registry.get_package "dummy" local ctx = test_helpers.create_context() stub(fs.async, "file_exists") @@ -70,7 +69,6 @@ describe("linker", function() end) it("should write executable wrapper on Windows", function() - local dummy = registry.get_package "dummy" local ctx = test_helpers.create_context() platform.is.darwin = false @@ -110,7 +108,6 @@ describe("linker", function() end) it("should symlink share files", function() - local dummy = registry.get_package "dummy" local ctx = test_helpers.create_context() stub(fs.async, "mkdirp") @@ -150,7 +147,6 @@ describe("linker", function() end) it("should copy share files on Windows", function() - local dummy = registry.get_package "dummy" local ctx = test_helpers.create_context() platform.is.darwin = false diff --git a/tests/mason-core/package/package_spec.lua b/tests/mason-core/package/package_spec.lua index 5f69ea4e..8d1929d8 100644 --- a/tests/mason-core/package/package_spec.lua +++ b/tests/mason-core/package/package_spec.lua @@ -42,8 +42,8 @@ describe("Package ::", function() name = "Package name", description = "Package description", homepage = "https://example.com", - categories = { Pkg.Cat.LSP }, - languages = { Pkg.Lang.Rust }, + categories = { "LSP" }, + languages = { "Rust" }, licenses = {}, source = { id = "pkg:mason/package@1", diff --git a/tests/mason-registry/sources/lua_spec.lua b/tests/mason-registry/sources/lua_spec.lua index c720ae10..9e3c8450 100644 --- a/tests/mason-registry/sources/lua_spec.lua +++ b/tests/mason-registry/sources/lua_spec.lua @@ -2,44 +2,37 @@ local LuaRegistrySource = require "mason-registry.sources.lua" describe("Lua registry source", function() it("should get package", function() - package.loaded["pkg-index"] = { - ["my-pkg"] = "pkg-index.my-pkg", - } - package.loaded["pkg-index.my-pkg"] = {} local source = LuaRegistrySource:new { - mod = "pkg-index", + mod = "dummy-registry.index", } - assert.is_not_nil(source:get_package "my-pkg") + assert.is_true(source:install():is_success()) + assert.is_not_nil(source:get_package "dummy") assert.is_nil(source:get_package "non-existent") end) it("should get all package names", function() - package.loaded["pkg-index"] = { - ["my-pkg"] = "pkg-index.my-pkg", - ["rust-analyzer"] = "pkg-index.rust-analyzer", - ["typescript-language-server"] = "pkg-index.typescript-language-server", - } local source = LuaRegistrySource:new { - mod = "pkg-index", + mod = "dummy-registry.index", } + assert.is_true(source:install():is_success()) local package_names = source:get_all_package_names() table.sort(package_names) assert.same({ - "my-pkg", - "rust-analyzer", - "typescript-language-server", + "dummy", + "dummy2", + "registry", }, package_names) end) it("should check if is installed", function() - package.loaded["pkg-index"] = {} local installed_source = LuaRegistrySource:new { - mod = "pkg-index", + mod = "dummy-registry.index", } local uninstalled_source = LuaRegistrySource:new { mod = "non-existent", } + assert.is_true(installed_source:install():is_success()) assert.is_true(installed_source:is_installed()) assert.is_false(uninstalled_source:is_installed()) end) diff --git a/tests/minimal_init.vim b/tests/minimal_init.vim index 43e8367f..e573ec1d 100644 --- a/tests/minimal_init.vim +++ b/tests/minimal_init.vim @@ -40,6 +40,8 @@ require("mason").setup { "lua:dummy-registry.index" } } + +require("mason-registry").refresh() EOF function! RunTests() abort |
