From 07d949a21aff4c8a379a36ac3e457027efe3a1fe Mon Sep 17 00:00:00 2001 From: William Boman Date: Wed, 14 Sep 2022 14:40:38 +0200 Subject: fix(r-languageserver): use github releases as version source (#417) --- tests/mason-core/managers/github_spec.lua | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests/mason-core/managers/github_spec.lua') diff --git a/tests/mason-core/managers/github_spec.lua b/tests/mason-core/managers/github_spec.lua index 7d44f144..c0285519 100644 --- a/tests/mason-core/managers/github_spec.lua +++ b/tests/mason-core/managers/github_spec.lua @@ -23,6 +23,10 @@ describe("github release file", function() end) assert.spy(client.fetch_latest_release).was_not_called() assert.equals("13.37", source.release) + assert.equals( + "https://github.com/williamboman/mason.nvim/releases/download/13.37/program.exe", + source.download_url + ) end) ) @@ -47,6 +51,49 @@ describe("github release file", function() 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) + assert.equals( + "https://github.com/williamboman/mason.nvim/releases/download/im_the_tag/im_the_tag_for_reals", + source.download_url + ) + end) + ) +end) + +describe("github release version", 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_version { + repo = "williamboman/mason.nvim", + version = Optional.of "13.37", + } + end) + assert.spy(client.fetch_latest_release).was_not_called() + assert.equals("13.37", source.release) + end) + ) + + it( + "should fetch latest release from GitHub API", + async_test(function() + async_test(function() + stub(client, "fetch_latest_release") + client.fetch_latest_release.returns(Result.success { tag_name = "v42" }) + local handle = InstallHandleGenerator "dummy" + local ctx = InstallContextGenerator(handle) + local source = installer.run_installer(ctx, function() + return github.release_version { + repo = "williamboman/mason.nvim", + } + end) + assert.spy(client.fetch_latest_release).was_called(1) + assert.spy(client.fetch_latest_release).was_called_with "williamboman/mason.nvim" + assert.equals("v42", source.release) + end) end) ) end) -- cgit v1.2.3-70-g09d2