MCPcopy
hub / github.com/gofiber/fiber / Test_item_Decode_FieldLimits

Function Test_item_Decode_FieldLimits

middleware/cache/coverage_test.go:251–277  ·  view source on GitHub ↗

Test_item_Decode_FieldLimits covers the per-field ErrLimitExceeded branches of the item byte fields.

(t *testing.T)

Source from the content-addressed store, hash-verified

249// Test_item_Decode_FieldLimits covers the per-field ErrLimitExceeded branches
250// of the item byte fields.
251func Test_item_Decode_FieldLimits(t *testing.T) {
252 t.Parallel()
253
254 cases := []struct {
255 field string
256 size int
257 }{
258 {"ctype", 257},
259 {"cencoding", 129},
260 {"cacheControl", 2049},
261 {"expires", 129},
262 {"etag", 257},
263 }
264 for _, tc := range cases {
265 var raw []byte
266 raw = msgp.AppendMapHeader(raw, 1)
267 raw = msgp.AppendString(raw, tc.field)
268 raw = msgp.AppendBytes(raw, make([]byte, tc.size))
269
270 var out item
271 _, err := out.UnmarshalMsg(raw)
272 require.ErrorIs(t, err, msgp.ErrLimitExceeded, "field %s", tc.field)
273
274 var dec item
275 require.ErrorIs(t, dec.DecodeMsg(msgp.NewReader(bytes.NewReader(raw))), msgp.ErrLimitExceeded, "field %s", tc.field)
276 }
277}
278
279func Test_indexedHeap_PushAndOps(t *testing.T) {
280 t.Parallel()

Callers

nothing calls this directly

Calls 2

UnmarshalMsgMethod · 0.95
DecodeMsgMethod · 0.95

Tested by

no test coverage detected