Software /
code /
prosody
Comparison
spec/util_async_spec.lua @ 8681:0c077800cd70
util.async: Make parameters to async.runner() optional
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 23 Mar 2018 14:02:33 +0000 |
parent | 8669:2aa85b0cd2b8 |
child | 8683:867ac771fb6e |
comparison
equal
deleted
inserted
replaced
8680:1cc9a293e958 | 8681:0c077800cd70 |
---|---|
90 assert.spy(s).was.called(#values); | 90 assert.spy(s).was.called(#values); |
91 for i = 1, #values do | 91 for i = 1, #values do |
92 assert.spy(s).was.called_with(values[i]); | 92 assert.spy(s).was.called_with(values[i]); |
93 end | 93 end |
94 assert.equal(last_item, values[#values]); | 94 assert.equal(last_item, values[#values]); |
95 end); | |
96 | |
97 it("should work with no parameters", function () | |
98 local item = "fail"; | |
99 local r = async.runner(); | |
100 local f = spy.new(function () item = "success"; end); | |
101 r:run(f); | |
102 assert.spy(f).was.called(); | |
103 assert.equal(item, "success"); | |
104 end); | |
105 | |
106 it("supports a default error handler", function () | |
107 local item = "fail"; | |
108 local r = async.runner(); | |
109 local f = spy.new(function () error("test error"); end); | |
110 assert.error_matches(function () | |
111 r:run(f); | |
112 end, "test error"); | |
113 assert.spy(f).was.called(); | |
114 assert.equal(item, "fail"); | |
95 end); | 115 end); |
96 | 116 |
97 describe("#errors", function () | 117 describe("#errors", function () |
98 describe("should notify", function () | 118 describe("should notify", function () |
99 local last_processed_item, last_error; | 119 local last_processed_item, last_error; |