1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
package calls
// go generate -import github.com/mesos/mesos-go/api/v1/lib/agent -type C:agent.Call
// GENERATED CODE FOLLOWS; DO NOT EDIT.
import (
"context"
"testing"
"github.com/mesos/mesos-go/api/v1/lib"
"github.com/mesos/mesos-go/api/v1/lib/agent"
)
func TestNonStreaming(t *testing.T) {
c := new(agent.Call)
f := NonStreaming(c)
if x := f.Call(); x != c {
t.Fatalf("expected %#v instead of %#v", c, x)
}
if x := f.Marshaler(); x == nil {
t.Fatal("expected non-nil Marshaler")
}
f = NonStreaming(nil)
if x := f.Marshaler(); x != nil {
t.Fatalf("expected nil Marshaler instead of %#v", x)
}
}
func TestStreaming(t *testing.T) {
f := Empty()
f.IsStreaming()
if x := f.Call(); x != nil {
t.Fatalf("expected nil Call instead of %#v", x)
}
if x := f.Marshaler(); x != nil {
t.Fatalf("expected nil Call instead of %#v", x)
}
c := new(agent.Call)
f = f.Push(c)
if x := f.Marshaler(); x == nil {
t.Fatal("expected non-nil Marshaler")
}
if x := f.Marshaler(); x != nil {
t.Fatalf("expected nil Marshaler instead of %#v", x)
}
c2 := new(agent.Call)
f = Empty().Push(c, c2)
if x := f.Call(); x != c {
t.Fatalf("expected %#v instead of %#v", c, x)
}
if x := f.Call(); x != c2 {
t.Fatalf("expected %#v instead of %#v", c2, x)
}
if x := f.Call(); x != nil {
t.Fatalf("expected nil Call instead of %#v", x)
}
ch := make(chan *agent.Call, 2)
ch <- c
ch <- c2
close(ch)
f = FromChan(ch)
if x := f.Call(); x != c {
t.Fatalf("expected %#v instead of %#v", c, x)
}
if x := f.Call(); x != c2 {
t.Fatalf("expected %#v instead of %#v", c2, x)
}
if x := f.Call(); x != nil {
t.Fatalf("expected nil Call instead of %#v", x)
}
f = FromChan(nil)
if x := f.Call(); x != nil {
t.Fatalf("expected nil Call instead of %#v", x)
}
}
func TestIgnoreResponse(t *testing.T) {
var closed bool
IgnoreResponse(SenderFunc(func(_ context.Context, _ Request) (mesos.Response, error) {
return &mesos.ResponseWrapper{Closer: mesos.CloseFunc(func() error {
closed = true
return nil
})}, nil
})).Send(nil, nil)
if !closed {
t.Fatal("expected response to be closed")
}
}
|