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

Function TestJSUPWriter

api/queryio/jsup_test.go:16–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestJSUPWriter(t *testing.T) {
17 const record = `{x:1}`
18 const expected = `
19{"type":"QueryChannelSet","value":{"channel":"main"}}
20{"type":{"kind":"record","id":31,"fields":[{"name":"x","type":{"kind":"primitive","name":"int64"},"opt":false}]},"value":["1"]}
21{"type":"QueryChannelEnd","value":{"channel":"main"}}
22{"type":"QueryError","value":{"error":"test.err"}}
23`
24 var buf bytes.Buffer
25 w := queryio.NewJSUPWriter(&buf)
26 err := w.WriteControl(api.QueryChannelSet{Channel: "main"})
27 require.NoError(t, err)
28 sctx := super.NewContext()
29 vals := sbuf.NewArray([]super.Value{sup.MustParseValue(sctx, record)})
30 err = w.Push(sbuf.Dematerialize(sctx, vals))
31 require.NoError(t, err)
32 err = w.WriteControl(api.QueryChannelEnd{Channel: "main"})
33 require.NoError(t, err)
34 err = w.WriteControl(api.QueryError{Error: "test.err"})
35 require.NoError(t, err)
36 assert.Equal(t, expected, "\n"+buf.String())
37}

Callers

nothing calls this directly

Calls 9

WriteControlMethod · 0.95
PushMethod · 0.95
NewJSUPWriterFunction · 0.92
NewContextFunction · 0.92
NewArrayFunction · 0.92
MustParseValueFunction · 0.92
DematerializeFunction · 0.92
StringMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected