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

Function TestReadFrameInvalidTag

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

Source from the content-addressed store, hash-verified

82}
83
84func TestReadFrameInvalidTag(t *testing.T) {
85 t.Parallel()
86
87 // Hand construct a header that indicates a tag we don't know about. We just
88 // write the header to buf because we expect codec.ReadFrame to bail out when
89 // reading the invalid tag.
90 const (
91 dataLength uint32 = 10
92 bogusTag uint32 = 222
93 )
94 header := bogusTag<<codec.DataLength | dataLength
95 data := make([]byte, 4)
96 binary.BigEndian.PutUint32(data, header)
97
98 var buf bytes.Buffer
99 _, err := buf.Write(data)
100 require.NoError(t, err)
101
102 readBuf := make([]byte, 1)
103 _, _, err = codec.ReadFrame(&buf, readBuf)
104 require.ErrorIs(t, err, codec.ErrUnsupportedTag)
105}
106
107func TestReadFrameAllocatesWhenNeeded(t *testing.T) {
108 t.Parallel()

Callers

nothing calls this directly

Calls 2

ReadFrameFunction · 0.92
WriteMethod · 0.65

Tested by

no test coverage detected