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

Function TestSharedState_EmptyKeyBehavior

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

Source from the content-addressed store, hash-verified

717}
718
719func TestSharedState_EmptyKeyBehavior(t *testing.T) {
720 t.Parallel()
721
722 app := New(Config{SharedStorage: newSharedStateMemoryStorage(t)})
723
724 require.NoError(t, app.SharedState().Set("", []byte("raw"), time.Minute))
725 require.NoError(t, app.SharedState().SetJSON("", Map{"v": 1}, time.Minute))
726 require.NoError(t, app.SharedState().SetMsgPack("", Map{"v": 1}, time.Minute))
727 require.NoError(t, app.SharedState().SetCBOR("", Map{"v": 1}, time.Minute))
728 require.NoError(t, app.SharedState().SetXML("", Map{"v": 1}, time.Minute))
729
730 raw, found, err := app.SharedState().Get("")
731 require.NoError(t, err)
732 require.Nil(t, raw)
733 require.False(t, found)
734
735 _, found, err = app.SharedState().GetJSON("", &Map{})
736 require.NoError(t, err)
737 require.False(t, found)
738
739 _, found, err = app.SharedState().GetMsgPack("", &Map{})
740 require.NoError(t, err)
741 require.False(t, found)
742
743 _, found, err = app.SharedState().GetCBOR("", &Map{})
744 require.NoError(t, err)
745 require.False(t, found)
746
747 _, found, err = app.SharedState().GetXML("", &Map{})
748 require.NoError(t, err)
749 require.False(t, found)
750
751 require.NoError(t, app.SharedState().Delete(""))
752
753 has, err := app.SharedState().Has("")
754 require.NoError(t, err)
755 require.False(t, has)
756}

Callers

nothing calls this directly

Calls 15

SharedStateMethod · 0.80
SetMsgPackMethod · 0.80
GetJSONMethod · 0.80
GetMsgPackMethod · 0.80
GetCBORMethod · 0.80
GetXMLMethod · 0.80
NewFunction · 0.70
SetMethod · 0.65
GetMethod · 0.65
DeleteMethod · 0.65
SetJSONMethod · 0.45

Tested by

no test coverage detected