diff options
| author | William Boman <william@redwill.se> | 2023-03-14 04:48:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-14 04:48:03 +0100 |
| commit | bf087883b05082a07ec2abe22e904b227b21f0d3 (patch) | |
| tree | 2a024f842fb0be4ce91f325af08ecc0028299a6f /tests | |
| parent | fix(sources): also set .desc property when updating spec (#1095) (diff) | |
| download | mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.gz mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.bz2 mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.lz mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.xz mason-bf087883b05082a07ec2abe22e904b227b21f0d3.tar.zst mason-bf087883b05082a07ec2abe22e904b227b21f0d3.zip | |
feat: add registry.refresh() method (#1096)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mason/api/command_spec.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/mason/api/command_spec.lua b/tests/mason/api/command_spec.lua index aee08f6f..7b77bae3 100644 --- a/tests/mason/api/command_spec.lua +++ b/tests/mason/api/command_spec.lua @@ -1,6 +1,7 @@ local log = require "mason-core.log" local match = require "luassert.match" local spy = require "luassert.spy" +local stub = require "luassert.stub" local Pkg = require "mason-core.package" local a = require "mason-core.async" @@ -88,3 +89,43 @@ describe(":MasonLog", function() end) end) end) + +describe(":MasonUpdate", function() + it( + "should update registries", + async_test(function() + stub(registry, "update", function(cb) + cb(true, { {} }) + end) + spy.on(vim, "notify") + api.MasonUpdate() + assert.spy(vim.notify).was_called(1) + assert.spy(vim.notify).was_called_with("Updating registries…", vim.log.levels.INFO, { + title = "mason.nvim", + }) + a.scheduler() + assert.spy(vim.notify).was_called_with("Successfully updated 1 registry.", vim.log.levels.INFO, { + title = "mason.nvim", + }) + end) + ) + + it( + "should notify errors", + async_test(function() + stub(registry, "update", function(cb) + cb(false, "Some error.") + end) + spy.on(vim, "notify") + api.MasonUpdate() + assert.spy(vim.notify).was_called(1) + assert.spy(vim.notify).was_called_with("Updating registries…", vim.log.levels.INFO, { + title = "mason.nvim", + }) + a.scheduler() + assert.spy(vim.notify).was_called_with("Failed to update registries: Some error.", vim.log.levels.ERROR, { + title = "mason.nvim", + }) + end) + ) +end) |
