aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-08-15 21:37:38 +0200
committerGitHub <noreply@github.com>2022-08-15 19:37:38 +0000
commit68d3d554e6d003ef01964f968fb1e44c14d87522 (patch)
tree7c17d39a1473e8eaa969adfac5f5adb4e32dcb7b /tests/mason-core
parentfix(github): fix resolving asset file (#298) (diff)
downloadmason-68d3d554e6d003ef01964f968fb1e44c14d87522.tar
mason-68d3d554e6d003ef01964f968fb1e44c14d87522.tar.gz
mason-68d3d554e6d003ef01964f968fb1e44c14d87522.tar.bz2
mason-68d3d554e6d003ef01964f968fb1e44c14d87522.tar.lz
mason-68d3d554e6d003ef01964f968fb1e44c14d87522.tar.xz
mason-68d3d554e6d003ef01964f968fb1e44c14d87522.tar.zst
mason-68d3d554e6d003ef01964f968fb1e44c14d87522.zip
test(github): add spec file for the github manager (#299)
Diffstat (limited to 'tests/mason-core')
-rw-r--r--tests/mason-core/managers/github_spec.lua52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/mason-core/managers/github_spec.lua b/tests/mason-core/managers/github_spec.lua
new file mode 100644
index 00000000..7d44f144
--- /dev/null
+++ b/tests/mason-core/managers/github_spec.lua
@@ -0,0 +1,52 @@
+local stub = require "luassert.stub"
+local mock = require "luassert.mock"
+
+local Result = require "mason-core.result"
+local installer = require "mason-core.installer"
+local github = require "mason-core.managers.github"
+local Optional = require "mason-core.optional"
+local client = require "mason-core.managers.github.client"
+
+describe("github release file", function()
+ it(
+ "should use provided version",
+ async_test(function()
+ stub(client, "fetch_latest_release")
+ local handle = InstallHandleGenerator "dummy"
+ local ctx = InstallContextGenerator(handle)
+ local source = installer.run_installer(ctx, function()
+ return github.release_file {
+ repo = "williamboman/mason.nvim",
+ asset_file = "program.exe",
+ version = Optional.of "13.37",
+ }
+ end)
+ assert.spy(client.fetch_latest_release).was_not_called()
+ assert.equals("13.37", source.release)
+ end)
+ )
+
+ it(
+ "should use use dynamic asset_file",
+ async_test(function()
+ stub(client, "fetch_latest_release")
+ client.fetch_latest_release.returns(Result.success(mock.new {
+ tag_name = "im_the_tag",
+ }))
+ local handle = InstallHandleGenerator "dummy"
+ local ctx = InstallContextGenerator(handle)
+ local source = installer.run_installer(ctx, function()
+ return github.release_file {
+ repo = "williamboman/mason.nvim",
+ asset_file = function(version)
+ return version .. "_for_reals"
+ end,
+ }
+ end)
+ assert.spy(client.fetch_latest_release).was_called(1)
+ assert.spy(client.fetch_latest_release).was_called_with "williamboman/mason.nvim"
+ assert.equals("im_the_tag", source.release)
+ assert.equals("im_the_tag_for_reals", source.asset_file)
+ end)
+ )
+end)