aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-10-18 12:03:33 +0100
committerMatthew Wild <mwild1@gmail.com>2018-10-18 12:03:33 +0100
commit90b256a19dbf96d6b3af5252c3df158c0a619b3f (patch)
tree72ea46560789eb48b9d5958042fbd30a036867ca
parent22839913a54a1c3371d5f690520eb88145efbb25 (diff)
downloadprosody-90b256a19dbf96d6b3af5252c3df158c0a619b3f.tar.gz
prosody-90b256a19dbf96d6b3af5252c3df158c0a619b3f.zip
util.promise: Fix promise.reject() to return a rejected promise, and fix buggy test for it
-rw-r--r--spec/util_promise_spec.lua2
-rw-r--r--util/promise.lua2
2 files changed, 2 insertions, 2 deletions
diff --git a/spec/util_promise_spec.lua b/spec/util_promise_spec.lua
index d9cb235e..ae3df29f 100644
--- a/spec/util_promise_spec.lua
+++ b/spec/util_promise_spec.lua
@@ -253,7 +253,7 @@ describe("util.promise", function ()
it("returns a rejected promise", function ()
local p = promise.reject("foo");
local cb = spy.new(function () end);
- p:next(cb);
+ p:catch(cb);
assert.spy(cb).was_called(1);
assert.spy(cb).was_called_with("foo");
end);
diff --git a/util/promise.lua b/util/promise.lua
index 7184f5fb..1f48eb9f 100644
--- a/util/promise.lua
+++ b/util/promise.lua
@@ -119,7 +119,7 @@ local function resolve(v)
end
local function reject(v)
- return new(function (_reject)
+ return new(function (_, _reject)
_reject(v);
end);
end