aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-17 18:23:39 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-17 18:23:39 +0000
commit86ac07d8bc4a6c9486f890827e0d887504b4c890 (patch)
tree6c53e23fac2581f18b2928e4d5291f811a4564fd
parent62e076edbbaddeac1664d107d25c25fc9b9db385 (diff)
downloadprosody-86ac07d8bc4a6c9486f890827e0d887504b4c890.tar.gz
prosody-86ac07d8bc4a6c9486f890827e0d887504b4c890.zip
util.async: tests: Ensure done() can be called before wait()
-rw-r--r--spec/util_async_spec.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/util_async_spec.lua b/spec/util_async_spec.lua
index 7cd125b7..5b27c17b 100644
--- a/spec/util_async_spec.lua
+++ b/spec/util_async_spec.lua
@@ -533,5 +533,23 @@ describe("util.async", function()
assert.equal(r1.state, "ready");
--for k, v in ipairs(l1) do print(k,v) end
end);
+
+ it("should allow done() to be called before wait()", function ()
+ local processed_item;
+ local rf = spy.new(function (item)
+ local wait, done = async.waiter();
+ done();
+ wait();
+ processed_item = item;
+ end);
+ local r = async.runner(rf, mock_watchers());
+ r:run("test");
+ assert.equal(processed_item, "test");
+ assert.equal(r.state, "ready");
+ -- Since the observable state did not change,
+ -- the watchers should not have been called
+ assert.spy(r.watchers.waiting).was_not.called();
+ assert.spy(r.watchers.ready).was_not.called();
+ end);
end);
end);