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

Function TestSharedState_SetGet_RawDataKinds

shared_state_test.go:480–506  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

478}
479
480func TestSharedState_SetGet_RawDataKinds(t *testing.T) {
481 t.Parallel()
482
483 app := New(Config{SharedStorage: newSharedStateMemoryStorage(t)})
484
485 testCases := []struct {
486 key string
487 value []byte
488 }{
489 {key: "plain", value: []byte("text")},
490 {key: "json", value: []byte(`{"id":42}`)},
491 {key: "binary", value: []byte{0x00, 0xFF, 0x10, 0x7F}},
492 }
493
494 for _, tc := range testCases {
495 t.Run(tc.key, func(t *testing.T) {
496 t.Parallel()
497
498 require.NoError(t, app.SharedState().Set(tc.key, tc.value, time.Minute))
499
500 got, found, err := app.SharedState().Get(tc.key)
501 require.NoError(t, err)
502 require.True(t, found)
503 require.Equal(t, tc.value, got)
504 })
505 }
506}
507
508func TestSharedState_SetGet_JSONDataKinds(t *testing.T) {
509 t.Parallel()

Callers

nothing calls this directly

Calls 5

SharedStateMethod · 0.80
NewFunction · 0.70
SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected