Skip to content

Commit

Permalink
testsuite: lua/t0001-send-recv.t: test msg:respond()
Browse files Browse the repository at this point in the history
Extend the t0001-send-recv.t Lua test to test msg:respond() by
opening a flux handle using the "loop" connector, and sending a
request/response across the connector using msg:respond().
  • Loading branch information
grondo committed May 16, 2018
1 parent 146f227 commit e1513e0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion t/lua/t0001-send-recv.t
Expand Up @@ -5,7 +5,7 @@
local t = require 'fluxometer'.init (...)
t:start_session { size = 2}

plan (22)
plan (34)

local flux = require_ok ('flux')
local f, err = flux.new()
Expand Down Expand Up @@ -58,6 +58,29 @@ is (msg.data.seq, "1", "recv: got expected ping sequence")
is (msg.data.pad, "xxxxxx", "recv: got expected ping pad")
is (msg.tag, "cmb.ping", "recv: got expected tag on ping response")


f, err = flux.new ("loop://")
type_ok (f, 'userdata', "create loop connector")
is (err, nil, "error is nil")

local rc, err = f:send ("test", {foo = "bar"}, 0)
isnt (rc, 0, "loop: send over loop connector works")
is (err, nil, "loop: err is nil")

local msg, err = f:recvmsg ()
ok (msg, "loop: recvmsg: msg is non-nil")
ok (msg.type, "request", "loop: recvmsg: msg.type is correct")
is (msg.tag, "test", "loop: got expected message tag")
is (msg.data.foo, "bar", "loop: recvd message with expected payload")

msg:respond { bar = "baz" }

local msg, err = f:recvmsg ()
ok (msg, "loop: got response")
ok (msg.type, "response", "loop: recvmsg response")
ok (msg.tag, "test", "response: msg.tag is correct")
ok (msg.data.bar, "baz", "response: msg.data payload is correct")

done_testing ()

-- vi: ts=4 sw=4 expandtab

0 comments on commit e1513e0

Please sign in to comment.