File: calls_test.go

package info (click to toggle)
golang-github-mesos-mesos-go 0.0.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 11,724 kB
  • sloc: makefile: 163
file content (71 lines) | stat: -rw-r--r-- 1,570 bytes parent folder | download
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
package calls_test

import (
	"context"
	"time"

	"github.com/mesos/mesos-go/api/v1/lib"
	"github.com/mesos/mesos-go/api/v1/lib/agent"
	. "github.com/mesos/mesos-go/api/v1/lib/agent/calls"
)

func Example() {
	var (
		check = func(err error) {
			if err != nil {
				panic(err)
			}
		}
		swallow = func(_ mesos.Response, err error) { check(err) }

		ctx       = context.Background()
		sender    = SenderFunc(func(_ context.Context, _ Request) (_ mesos.Response, _ error) { return })
		blackhole = func(calls ...*agent.Call) {
			for i := range calls {
				swallow(sender.Send(ctx, NonStreaming(calls[i])))
			}
		}

		d = time.Duration(0)
	)
	blackhole(
		GetHealth(),
		GetFlags(),
		GetVersion(),
		GetMetrics(nil),
		GetMetrics(&d),
		GetLoggingLevel(),
		ListFiles(""),
		ReadFile("", 0),
		ReadFileWithLength("", 0, 0),
		GetState(),
		GetContainers(),
		GetFrameworks(),
		GetExecutors(),
		GetTasks(),
		GetAgent(),
		WaitNestedContainer(mesos.ContainerID{}),
		LaunchNestedContainerSession(mesos.ContainerID{}, nil, nil),
	)

	blackhole = func(calls ...*agent.Call) {
		for i := range calls {
			check(SendNoData(ctx, sender, NonStreaming(calls[i])))
		}
	}
	blackhole(
		SetLoggingLevel(0, d),
		LaunchNestedContainer(mesos.ContainerID{}, nil, nil),
		KillNestedContainer(mesos.ContainerID{}),
		RemoveNestedContainer(mesos.ContainerID{}),
		AttachContainerOutput(mesos.ContainerID{}),
	)

	swallow(sender.Send(ctx, Empty().Push(
		AttachContainerInput(mesos.ContainerID{}),
		AttachContainerInputTTY(nil),
		AttachContainerInputData(nil),
	)))

	// Output:
}