Debian Codegraph @

api/v1/lib/agent/calls/calls_generated_test.go

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