inmem: more testing

Signed-off-by: Solomon Hykes <solomon@docker.com>
This commit is contained in:
Solomon Hykes 2014-05-10 23:25:54 +00:00
parent 338a7d50a8
commit a5cb570bfb
1 changed files with 49 additions and 0 deletions

View File

@ -104,3 +104,52 @@ func TestSendReply(t *testing.T) {
}
})
}
func TestSendNested(t *testing.T) {
r, w := Pipe()
defer r.Close()
defer w.Close()
testutils.Timeout(t, func() {
// Send
go func() {
// Send a message with mode=W
in, out, err := w.Send(&Message{Data: "this is the request"}, W)
if err != nil {
t.Fatal(err)
}
if out == nil {
t.Fatalf("%#v", out)
}
if in != nil {
t.Fatalf("%#v", in)
}
// Send a nested message
_, _, err = out.Send(&Message{Data: "this is the nested message"}, 0)
if err != nil {
t.Fatal(err)
}
}()
// Receive a message with mode=R
msg, in, out, err := r.Receive(R)
if err != nil {
t.Fatal(err)
}
if msg.Data != "this is the request" {
t.Fatalf("%#v", msg)
}
if out != nil {
t.Fatalf("%#v", out)
}
if in == nil {
t.Fatalf("%#v", in)
}
// Read for a nested message
nested, _, _, err := in.Receive(0)
if err != nil {
t.Fatal(err)
}
if nested.Data != "this is the nested message" {
t.Fatalf("%#v", nested)
}
})
}