MCPcopy Create free account
hub / github.com/brimdata/super / TestReadOneLineNoEOF

Function TestReadOneLineNoEOF

sio/supio/reader_test.go:15–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestReadOneLineNoEOF(t *testing.T) {
16 const expected = `{msg:"record1"}`
17 type result struct {
18 err error
19 val *super.Value
20 }
21 done := make(chan result)
22 go func() {
23 var reader slowStream = make(chan []byte, 1)
24 // The test needs two records because with a single record the parser
25 // will stall waiting to see if the record has a decorator.
26 reader <- []byte(expected + "\n" + expected)
27 r := supio.NewReader(super.NewContext(), reader)
28 rec, err := r.Read()
29 done <- result{val: rec, err: err}
30 }()
31 select {
32 // Because this test CAN deadlock fail after 5 seconds.
33 case <-time.After(time.Second * 5):
34 t.Fatal("testing did not complete in 5 seconds")
35 case res := <-done:
36 require.NoError(t, res.err)
37 rec := res.val
38 assert.Equal(t, expected, sup.String(rec))
39 }
40}
41
42type slowStream chan []byte
43

Callers

nothing calls this directly

Calls 6

ReadMethod · 0.95
NewReaderFunction · 0.92
NewContextFunction · 0.92
StringFunction · 0.92
AfterMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected