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

Function TestDisplay

internal/jsonstream/display_test.go:13–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestDisplay(t *testing.T) {
14 ctx, cancel := context.WithCancel(context.Background())
15 t.Cleanup(cancel)
16
17 client, server := io.Pipe()
18 t.Cleanup(func() {
19 assert.NilError(t, server.Close())
20 })
21
22 go func() {
23 for range 100 {
24 select {
25 case <-ctx.Done():
26 assert.NilError(t, server.Close(), "failed to close jsonmessage server")
27 return
28 default:
29 time.Sleep(100 * time.Millisecond)
30 }
31 }
32 }()
33
34 streamCtx, cancelStream := context.WithCancel(context.Background())
35 t.Cleanup(cancelStream)
36
37 done := make(chan error)
38 go func() {
39 done <- Display(streamCtx, client, streams.NewOut(io.Discard))
40 }()
41
42 cancelStream()
43
44 select {
45 case <-time.After(time.Second * 3):
46 case err := <-done:
47 assert.ErrorIs(t, err, context.Canceled)
48 }
49}

Callers

nothing calls this directly

Calls 2

DisplayFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…