From e9eb0048cecc577a1eec534485d3e010487b46a7 Mon Sep 17 00:00:00 2001 From: William Boman Date: Sat, 19 Aug 2023 08:31:07 +0200 Subject: feat(cargo): support fetching versions for git crates hosted on github (#1459) --- .../installer/registry/providers/cargo_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/mason-core') diff --git a/tests/mason-core/installer/registry/providers/cargo_spec.lua b/tests/mason-core/installer/registry/providers/cargo_spec.lua index 674164c2..d3468909 100644 --- a/tests/mason-core/installer/registry/providers/cargo_spec.lua +++ b/tests/mason-core/installer/registry/providers/cargo_spec.lua @@ -2,6 +2,7 @@ local Purl = require "mason-core.purl" local Result = require "mason-core.result" local cargo = require "mason-core.installer.registry.providers.cargo" local installer = require "mason-core.installer" +local providers = require "mason-core.providers" local stub = require "luassert.stub" ---@param overrides Purl @@ -117,3 +118,22 @@ describe("cargo provider :: installing", function() }) end) end) + +describe("cargo provider :: versions", function() + it("should recognize github cargo source", function() + stub(providers.github, "get_all_tags", function() + return Result.success { "1.0.0", "2.0.0", "3.0.0" } + end) + + local result = cargo.get_versions(purl { + qualifiers = { + repository_url = "https://github.com/rust-lang/rust-analyzer", + }, + }) + + assert.is_true(result:is_success()) + assert.same({ "1.0.0", "2.0.0", "3.0.0" }, result:get_or_throw()) + assert.spy(providers.github.get_all_tags).was_called(1) + assert.spy(providers.github.get_all_tags).was_called_with "rust-lang/rust-analyzer" + end) +end) -- cgit v1.2.3-70-g09d2