aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-10-09 23:41:42 +0200
committerGitHub <noreply@github.com>2022-10-09 23:41:42 +0200
commit3fa66adfc794238e0d0ae55c06403b3ea09d1cef (patch)
treeab33d0da2024b8eb1b9f6491e1e8db08e83f4c2e /tests/mason-core
parentfeat(npm): speed up checking for new versions (#530) (diff)
downloadmason-3fa66adfc794238e0d0ae55c06403b3ea09d1cef.tar
mason-3fa66adfc794238e0d0ae55c06403b3ea09d1cef.tar.gz
mason-3fa66adfc794238e0d0ae55c06403b3ea09d1cef.tar.bz2
mason-3fa66adfc794238e0d0ae55c06403b3ea09d1cef.tar.lz
mason-3fa66adfc794238e0d0ae55c06403b3ea09d1cef.tar.xz
mason-3fa66adfc794238e0d0ae55c06403b3ea09d1cef.tar.zst
mason-3fa66adfc794238e0d0ae55c06403b3ea09d1cef.zip
fix(fetch): set proper iwr header on Windows, reorder tool priority (#531)
Old priority: platform specific > wget > curl New priority: curl > wget > platform specific
Diffstat (limited to 'tests/mason-core')
-rw-r--r--tests/mason-core/result_spec.lua25
1 files changed, 23 insertions, 2 deletions
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)