From 3fa66adfc794238e0d0ae55c06403b3ea09d1cef Mon Sep 17 00:00:00 2001 From: William Boman Date: Sun, 9 Oct 2022 23:41:42 +0200 Subject: fix(fetch): set proper iwr header on Windows, reorder tool priority (#531) Old priority: platform specific > wget > curl New priority: curl > wget > platform specific --- tests/mason-core/result_spec.lua | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests/mason-core/result_spec.lua') diff --git a/tests/mason-core/result_spec.lua b/tests/mason-core/result_spec.lua index ee722281..1d8f36fb 100644 --- a/tests/mason-core/result_spec.lua +++ b/tests/mason-core/result_spec.lua @@ -154,7 +154,7 @@ describe("result", function() assert.is_false(opt:is_present()) end) - it("should chain results", function() + it("should chain successful results", function() local success = Result.success("First"):and_then(function(value) return Result.success(value .. " Second") end) @@ -166,7 +166,7 @@ describe("result", function() assert.equals("Error", failure:err_or_nil()) end) - it("should not chain results upon failure", function() + it("should not chain failed results", function() local chain = spy.new() local failure = Result.failure("Error"):and_then(chain) @@ -174,4 +174,25 @@ describe("result", function() assert.equals("Error", failure:err_or_nil()) assert.spy(chain).was_not_called() end) + + it("should chain failed results", function() + local failure = Result.failure("First"):or_else(function(value) + return Result.failure(value .. " Second") + end) + local success = Result.failure("Error"):or_else(Result.success) + + assert.is_true(success:is_success()) + assert.equals("Error", success:get_or_nil()) + assert.is_true(failure:is_failure()) + assert.equals("First Second", failure:err_or_nil()) + end) + + it("should not chain successful results", function() + local chain = spy.new() + local failure = Result.success("Error"):or_else(chain) + + assert.is_true(failure:is_success()) + assert.equals("Error", failure:get_or_nil()) + assert.spy(chain).was_not_called() + end) end) -- cgit v1.2.3-70-g09d2