aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-03-17 13:15:50 +0100
committerKim Alvefur <zash@zash.se>2022-03-17 13:15:50 +0100
commitd1c2e34e610477b901998f7230631f6c99166f9b (patch)
tree7089087e238e55a3f059e507298a69bf51dcde95 /spec
parent36fbcd47721f51abfd59ec3a58286c3c6aedd7e0 (diff)
downloadprosody-d1c2e34e610477b901998f7230631f6c99166f9b.tar.gz
prosody-d1c2e34e610477b901998f7230631f6c99166f9b.zip
util.poll: Expand stub tests
Because tests good.
Diffstat (limited to 'spec')
-rw-r--r--spec/util_poll_spec.lua35
1 files changed, 32 insertions, 3 deletions
diff --git a/spec/util_poll_spec.lua b/spec/util_poll_spec.lua
index a763be90..05318453 100644
--- a/spec/util_poll_spec.lua
+++ b/spec/util_poll_spec.lua
@@ -1,6 +1,35 @@
-describe("util.poll", function ()
- it("loads", function ()
- require "util.poll"
+describe("util.poll", function()
+ local poll;
+ setup(function()
+ poll = require "util.poll";
end);
+ it("loads", function()
+ assert.is_table(poll);
+ assert.is_function(poll.new);
+ assert.is_string(poll.api);
+ end);
+ describe("new", function()
+ local p;
+ setup(function()
+ p = poll.new();
+ end)
+ it("times out", function ()
+ local fd, err = p:wait(0);
+ assert.falsy(fd);
+ assert.equal("timeout", err);
+ end);
+ it("works", function()
+ -- stdout should be writable, right?
+ assert.truthy(p:add(1, false, true));
+ local fd, r, w = p:wait(1);
+ assert.is_number(fd);
+ assert.is_boolean(r);
+ assert.is_boolean(w);
+ assert.equal(1, fd);
+ assert.falsy(r);
+ assert.truthy(w);
+ assert.truthy(p:del(1));
+ end);
+ end)
end);