mirror of https://github.com/docker/docs.git
Test that beam/utils.StackSender works with beam/unix
[Signed-off-by: Solomon Hykes <solomon@docker.com>] [Signed-off-by: Paul Nasrat <pnasrat@gmail.com>]
This commit is contained in:
parent
c4c06fb39a
commit
384c505106
|
@ -3,12 +3,13 @@ package utils
|
|||
import (
|
||||
"github.com/docker/beam"
|
||||
"github.com/docker/beam/inmem"
|
||||
"github.com/docker/beam/unix"
|
||||
"github.com/dotcloud/docker/pkg/testutils"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSendStack(t *testing.T) {
|
||||
func TestStackWithPipe(t *testing.T) {
|
||||
r, w := inmem.Pipe()
|
||||
defer r.Close()
|
||||
defer w.Close()
|
||||
|
@ -34,6 +35,35 @@ func TestSendStack(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestStackWithPair(t *testing.T) {
|
||||
r, w, err := unix.Pair()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer r.Close()
|
||||
defer w.Close()
|
||||
s := NewStackSender()
|
||||
s.Add(w)
|
||||
testutils.Timeout(t, func() {
|
||||
go func() {
|
||||
msg, _, _, err := r.Receive(0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if msg.Name != "hello" {
|
||||
t.Fatalf("%#v", msg)
|
||||
}
|
||||
if strings.Join(msg.Args, " ") != "wonderful world" {
|
||||
t.Fatalf("%#v", msg)
|
||||
}
|
||||
}()
|
||||
_, _, err := s.Send(&beam.Message{"hello", []string{"wonderful", "world"}}, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestStackLen(t *testing.T) {
|
||||
s := NewStackSender()
|
||||
if s.Len() != 0 {
|
||||
|
|
Loading…
Reference in New Issue