MCPcopy Index your code
hub / github.com/docker/cli / TestForwardSignals

Function TestForwardSignals

cli/command/container/signals_test.go:13–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestForwardSignals(t *testing.T) {
14 ctx := t.Context()
15
16 called := make(chan struct{})
17 apiClient := &fakeClient{containerKillFunc: func(ctx context.Context, container string, options client.ContainerKillOptions) (client.ContainerKillResult, error) {
18 close(called)
19 return client.ContainerKillResult{}, nil
20 }}
21
22 sigc := make(chan os.Signal)
23 defer close(sigc)
24
25 go ForwardAllSignals(ctx, apiClient, t.Name(), sigc)
26
27 timer := time.NewTimer(30 * time.Second)
28 defer timer.Stop()
29
30 select {
31 case <-timer.C:
32 t.Fatal("timeout waiting to send signal")
33 case sigc <- signal.SignalMap["TERM"]:
34 }
35 if !timer.Stop() {
36 <-timer.C
37 }
38 timer.Reset(30 * time.Second)
39
40 select {
41 case <-called:
42 case <-timer.C:
43 t.Fatal("timeout waiting for signal to be processed")
44 }
45}

Callers

nothing calls this directly

Calls 2

ForwardAllSignalsFunction · 0.85
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…