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

Function TestReadFrameTooLarge

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

Source from the content-addressed store, hash-verified

54}
55
56func TestReadFrameTooLarge(t *testing.T) {
57 t.Parallel()
58
59 // Hand construct a header that indicates the message size exceeds the maximum
60 // message size for codec.TagV1 by one. We just write the header to buf because
61 // we expect codec.ReadFrame to bail out when reading the invalid length.
62 header := uint32(codec.TagV1)<<codec.DataLength | (codec.MaxMessageSizeV1 + 1)
63 data := make([]byte, 4)
64 binary.BigEndian.PutUint32(data, header)
65
66 var buf bytes.Buffer
67 _, err := buf.Write(data)
68 require.NoError(t, err)
69
70 readBuf := make([]byte, 1)
71 _, _, err = codec.ReadFrame(&buf, readBuf)
72 require.ErrorIs(t, err, codec.ErrMessageTooLarge)
73}
74
75func TestReadFrameEmptyReader(t *testing.T) {
76 t.Parallel()

Callers

nothing calls this directly

Calls 2

ReadFrameFunction · 0.92
WriteMethod · 0.65

Tested by

no test coverage detected