diff options
| author | William Boman <william@redwill.se> | 2022-10-04 12:04:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-04 10:04:13 +0000 |
| commit | 45606b0e9b01a1565bfc8b57a52ec04f58f5f295 (patch) | |
| tree | f464d7389b3b6acb4610d48d57110c6886621c2f | |
| parent | chore: update generated code (#507) (diff) | |
| download | mason-45606b0e9b01a1565bfc8b57a52ec04f58f5f295.tar mason-45606b0e9b01a1565bfc8b57a52ec04f58f5f295.tar.gz mason-45606b0e9b01a1565bfc8b57a52ec04f58f5f295.tar.bz2 mason-45606b0e9b01a1565bfc8b57a52ec04f58f5f295.tar.lz mason-45606b0e9b01a1565bfc8b57a52ec04f58f5f295.tar.xz mason-45606b0e9b01a1565bfc8b57a52ec04f58f5f295.tar.zst mason-45606b0e9b01a1565bfc8b57a52ec04f58f5f295.zip | |
test(cargo): stub crates.io http call (#508)
| -rw-r--r-- | tests/mason-core/managers/cargo_spec.lua | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/mason-core/managers/cargo_spec.lua b/tests/mason-core/managers/cargo_spec.lua index 31a54ae7..ddcb7300 100644 --- a/tests/mason-core/managers/cargo_spec.lua +++ b/tests/mason-core/managers/cargo_spec.lua @@ -1,8 +1,10 @@ +local stub = require "luassert.stub" local spy = require "luassert.spy" local match = require "luassert.match" local mock = require "luassert.mock" local installer = require "mason-core.installer" local cargo = require "mason-core.managers.cargo" +local client = require "mason-core.managers.cargo.client" local Result = require "mason-core.result" local spawn = require "mason-core.spawn" local path = require "mason-core.path" @@ -182,7 +184,6 @@ zoxide v0.5.0: end) ) - -- XXX: This test will actually send http request to crates.io's API. It's not mocked. it( "should return outdated primary package", async_test(function() @@ -193,6 +194,15 @@ zoxide v0.5.0: ]], } end) + stub(client, "fetch_crate") + client.fetch_crate.returns(Result.success { + crate = { + id = "lelwel", + max_stable_version = "0.4.2", + max_version = "0.4.2", + newest_version = "0.4.2", + }, + }) local result = cargo.check_outdated_primary_package( mock.new { @@ -215,7 +225,7 @@ zoxide v0.5.0: assert.is_true(result:is_success()) assert.is_true(match.tbl_containing { current_version = "0.4.0", - latest_version = match.matches "%d.%d.%d", + latest_version = "0.4.2", name = "lelwel", }(result:get_or_nil())) |
