aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-22 07:46:23 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-22 07:46:23 +0000
commit430eef84208c1e4a0d07a2b32d76dccea731ca13 (patch)
tree849da7e4f75b2bc0551d160f470f1601192e2fe5 /spec
parent8e469e0a76088d18886784fba9fc044c692987d4 (diff)
downloadprosody-430eef84208c1e4a0d07a2b32d76dccea731ca13.tar.gz
prosody-430eef84208c1e4a0d07a2b32d76dccea731ca13.zip
util.async: Add ready() to check whether running in async context
Diffstat (limited to 'spec')
-rw-r--r--spec/util_async_spec.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/util_async_spec.lua b/spec/util_async_spec.lua
index 58d54487..ac71e755 100644
--- a/spec/util_async_spec.lua
+++ b/spec/util_async_spec.lua
@@ -579,4 +579,18 @@ describe("util.async", function()
assert.spy(r.watchers.ready).was_not.called();
end);
end);
+
+ describe("#ready()", function ()
+ it("should return false outside an async context", function ()
+ assert.falsy(async.ready());
+ end);
+ it("should return true inside an async context", function ()
+ local r = new(function ()
+ assert.truthy(async.ready());
+ end);
+ r:run(true);
+ assert.spy(r.func).was.called();
+ assert.spy(r.watchers.error).was_not.called();
+ end);
+ end);
end);