aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-23 14:02:33 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-23 14:02:33 +0000
commita8f9a2757f09c1b9c83081034e5ef1106ff47d8d (patch)
tree9a66ab2c432a6f383fc2add6965d4df6d6e38c03 /spec
parent5303e726055769fcced5afb1b5ef7eff4b31a704 (diff)
downloadprosody-a8f9a2757f09c1b9c83081034e5ef1106ff47d8d.tar.gz
prosody-a8f9a2757f09c1b9c83081034e5ef1106ff47d8d.zip
util.async: Make parameters to async.runner() optional
Diffstat (limited to 'spec')
-rw-r--r--spec/util_async_spec.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/util_async_spec.lua b/spec/util_async_spec.lua
index 959ad65b..d81b18b5 100644
--- a/spec/util_async_spec.lua
+++ b/spec/util_async_spec.lua
@@ -94,6 +94,26 @@ describe("util.async", function()
assert.equal(last_item, values[#values]);
end);
+ it("should work with no parameters", function ()
+ local item = "fail";
+ local r = async.runner();
+ local f = spy.new(function () item = "success"; end);
+ r:run(f);
+ assert.spy(f).was.called();
+ assert.equal(item, "success");
+ end);
+
+ it("supports a default error handler", function ()
+ local item = "fail";
+ local r = async.runner();
+ local f = spy.new(function () error("test error"); end);
+ assert.error_matches(function ()
+ r:run(f);
+ end, "test error");
+ assert.spy(f).was.called();
+ assert.equal(item, "fail");
+ end);
+
describe("#errors", function ()
describe("should notify", function ()
local last_processed_item, last_error;