MCPcopy Index your code
hub / github.com/coder/coder / TestRoundTrip

Function TestRoundTrip

agent/boundarylogproxy/codec/codec_test.go:14–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestRoundTrip(t *testing.T) {
15 t.Parallel()
16
17 tests := []struct {
18 name string
19 tag codec.Tag
20 data []byte
21 }{
22 {
23 name: "empty data",
24 tag: codec.TagV1,
25 data: []byte{},
26 },
27 {
28 name: "simple data",
29 tag: codec.TagV1,
30 data: []byte("hello world"),
31 },
32 {
33 name: "binary data",
34 tag: codec.TagV1,
35 data: []byte{0x00, 0x01, 0x02, 0xff, 0xfe},
36 },
37 }
38
39 for _, tt := range tests {
40 t.Run(tt.name, func(t *testing.T) {
41 t.Parallel()
42
43 var buf bytes.Buffer
44 err := codec.WriteFrame(&buf, tt.tag, tt.data)
45 require.NoError(t, err)
46
47 readBuf := make([]byte, codec.MaxMessageSizeV1)
48 tag, data, err := codec.ReadFrame(&buf, readBuf)
49 require.NoError(t, err)
50 require.Equal(t, tt.tag, tag)
51 require.Equal(t, tt.data, data)
52 })
53 }
54}
55
56func TestReadFrameTooLarge(t *testing.T) {
57 t.Parallel()

Callers

nothing calls this directly

Calls 4

WriteFrameFunction · 0.92
ReadFrameFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected