aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-registry
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2026-05-18 23:23:19 +0200
committerGitHub <noreply@github.com>2026-05-18 23:23:19 +0200
commitcbf8d285e1462dd24acf3507817be2bbcb035919 (patch)
tree42a5b07705b1dd863bc47a2460073e433ab6e2a6 /tests/mason-registry
parentfeat: add the infrastructure to support "system" packages (#2085) (diff)
downloadmason-main.tar
mason-main.tar.gz
mason-main.tar.bz2
mason-main.tar.lz
mason-main.tar.xz
mason-main.tar.zst
mason-main.zip
feat(registry): add registry_cache setting for controlling cache behaviour (#2089)HEADmain
* feat(registry): add registry_cache setting for controlling cache behaviour * fix: call callback if available
Diffstat (limited to 'tests/mason-registry')
-rw-r--r--tests/mason-registry/registry_spec.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/mason-registry/registry_spec.lua b/tests/mason-registry/registry_spec.lua
index daa8fc9f..cf909667 100644
--- a/tests/mason-registry/registry_spec.lua
+++ b/tests/mason-registry/registry_spec.lua
@@ -1,5 +1,7 @@
local Pkg = require "mason-core.package"
+local match = require "luassert.match"
local registry = require "mason-registry"
+local spy = require "luassert.spy"
local test_helpers = require "mason-test.helpers"
describe("mason-registry", function()
@@ -33,4 +35,50 @@ describe("mason-registry", function()
test_helpers.sync_install(dummy)
assert.is_true(registry.is_installed "dummy")
end)
+
+ describe("refresh/update", function()
+ local a = require "mason-core.async"
+ local settings = require "mason.settings"
+ local installer = require "mason-registry.installer"
+
+ after_each(function()
+ settings.set(settings._DEFAULT_SETTINGS)
+ end)
+
+ it("should refresh registry synchronously", function()
+ local ok, updated_registries = registry.refresh()
+ assert.is_true(ok)
+ assert.same({}, updated_registries)
+ end)
+
+ it("should call registry.refresh callback", function()
+ local spy = spy.new()
+ registry.refresh(spy)
+ assert.wait(function()
+ assert.spy(spy).was_called(1)
+ assert.spy(spy).was_called_with(true, {})
+ end)
+ end)
+
+ it("should call registry.update callback", function()
+ local spy = spy.new()
+ registry.update(spy)
+ assert.wait(function()
+ assert.spy(spy).was_called(1)
+ assert.spy(spy).was_called_with(true, match.is_table())
+ end)
+ end)
+
+ it("should immediately return if refresh is disabled", function()
+ settings.current.registry_cache.refresh = false
+ local ok, registries = registry.refresh()
+ assert.is_true(ok)
+ assert.same({}, registries)
+
+ local spy = spy.new()
+ registry.refresh(spy)
+ assert.spy(spy).was_called(1)
+ assert.spy(spy).was_called_with(true, {})
+ end)
+ end)
end)