aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-09-14 17:58:11 +0200
committerGitHub <noreply@github.com>2022-09-14 17:58:11 +0200
commitd39e46db31c9b2eee458ca59a814ebc4fe8a5bd5 (patch)
treecac215882f0692cd2e181944210e768a32d23a58 /tests/mason-core
parentfix(r-languageserver): use github releases as version source (#417) (diff)
downloadmason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.gz
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.bz2
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.lz
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.xz
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.tar.zst
mason-d39e46db31c9b2eee458ca59a814ebc4fe8a5bd5.zip
refactor: store link state in install context object (#419)
Diffstat (limited to 'tests/mason-core')
-rw-r--r--tests/mason-core/installer/installer_spec.lua26
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/mason-core/installer/installer_spec.lua b/tests/mason-core/installer/installer_spec.lua
index 8dc9b516..ead08f18 100644
--- a/tests/mason-core/installer/installer_spec.lua
+++ b/tests/mason-core/installer/installer_spec.lua
@@ -57,12 +57,26 @@ describe("installer", function()
"should write receipt",
async_test(function()
spy.on(fs.async, "write_file")
- local handle = InstallHandleGenerator "dummy"
- installer.execute(handle, {})
- assert.spy(fs.async.write_file).was_called(1)
- assert
- .spy(fs.async.write_file)
- .was_called_with(("%s/mason-receipt.json"):format(handle.package:get_install_path()), match.is_string())
+ local handler = InstallHandleGenerator "dummy"
+ ---@param ctx InstallContext
+ handler.package.spec.install = function(ctx)
+ ctx.receipt:with_primary_source { type = "source", metadata = {} }
+ ctx.fs:write_file("target", "script-contents")
+ ctx:link_bin("executable", "target")
+ end
+ installer.execute(handler, {})
+ assert.spy(fs.async.write_file).was_called_with(
+ ("%s/mason-receipt.json"):format(handler.package:get_install_path()),
+ match.capture(function(arg)
+ ---@type InstallReceipt
+ local receipt = vim.json.decode(arg)
+ assert.equals("dummy", receipt.name)
+ assert.same({ type = "source", metadata = {} }, receipt.primary_source)
+ assert.same({}, receipt.secondary_sources)
+ assert.same("1.0", receipt.schema_version)
+ assert.same({ bin = { executable = "target" } }, receipt.links)
+ end)
+ )
end)
)