MCPcopy Create free account
hub / github.com/coder/coder / TestStdbuf

Function TestStdbuf

pty/ptytest/ptytest_internal_test.go:12–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestStdbuf(t *testing.T) {
13 t.Parallel()
14
15 var got bytes.Buffer
16
17 b := newStdbuf()
18 done := make(chan struct{})
19 go func() {
20 defer close(done)
21 _, err := io.Copy(&got, b)
22 assert.NoError(t, err)
23 }()
24
25 _, err := b.Write([]byte("hello "))
26 require.NoError(t, err)
27 _, err = b.Write([]byte("world\n"))
28 require.NoError(t, err)
29 _, err = b.Write([]byte("bye\n"))
30 require.NoError(t, err)
31
32 err = b.Close()
33 require.NoError(t, err)
34 <-done
35
36 assert.Equal(t, "hello world\nbye\n", got.String())
37}

Callers

nothing calls this directly

Calls 6

newStdbufFunction · 0.70
CopyMethod · 0.65
WriteMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected