aboutsummaryrefslogtreecommitdiffstats
path: root/tests/core/async/async_spec.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-03-26 13:41:50 +0100
committerGitHub <noreply@github.com>2022-03-26 13:41:50 +0100
commit212d17a039da449043b67529c29851db37acc236 (patch)
tree38411b14487895cef0d7648e198b79fd28793fe6 /tests/core/async/async_spec.lua
parentrun autogen_metadata.lua (diff)
downloadmason-212d17a039da449043b67529c29851db37acc236.tar
mason-212d17a039da449043b67529c29851db37acc236.tar.gz
mason-212d17a039da449043b67529c29851db37acc236.tar.bz2
mason-212d17a039da449043b67529c29851db37acc236.tar.lz
mason-212d17a039da449043b67529c29851db37acc236.tar.xz
mason-212d17a039da449043b67529c29851db37acc236.tar.zst
mason-212d17a039da449043b67529c29851db37acc236.zip
add async managers (#536)
Diffstat (limited to 'tests/core/async/async_spec.lua')
-rw-r--r--tests/core/async/async_spec.lua19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/core/async/async_spec.lua b/tests/core/async/async_spec.lua
index 662e493a..0e881c8b 100644
--- a/tests/core/async/async_spec.lua
+++ b/tests/core/async/async_spec.lua
@@ -13,14 +13,29 @@ describe("async", function()
it("should run in blocking mode", function()
local start = timestamp()
a.run_blocking(function()
- a.sleep(1000)
+ a.sleep(100)
end)
local stop = timestamp()
local grace_ms = 25
- assert.is_true((stop - start) >= (1000 - grace_ms))
+ assert.is_true((stop - start) >= (100 - grace_ms))
end)
it(
+ "should pass arguments to .run",
+ async_test(function()
+ local callback = spy.new()
+ local start = timestamp()
+ a.run(a.sleep, callback, 100)
+ assert.wait_for(function()
+ assert.spy(callback).was_called(1)
+ local stop = timestamp()
+ local grace_ms = 25
+ assert.is_true((stop - start) >= (100 - grace_ms))
+ end, 150)
+ end)
+ )
+
+ it(
"should wrap callback-style async functions",
async_test(function()
local stdio = process.in_memory_sink()