(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…