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

Function TestSharedState_NotConfigured

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

Source from the content-addressed store, hash-verified

114}
115
116func TestSharedState_NotConfigured(t *testing.T) {
117 t.Parallel()
118
119 app := New()
120
121 err := app.SharedState().Set("raw-key", []byte("raw"), time.Second)
122 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
123
124 raw, found, err := app.SharedState().Get("raw-key")
125 require.Nil(t, raw)
126 require.False(t, found)
127 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
128
129 err = app.SharedState().SetJSON("key", Map{"v": 1}, time.Second)
130 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
131 err = app.SharedState().SetMsgPack("key", Map{"v": 1}, time.Second)
132 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
133 err = app.SharedState().SetCBOR("key", Map{"v": 1}, time.Second)
134 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
135 err = app.SharedState().SetXML("key", Map{"v": 1}, time.Second)
136 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
137
138 _, found, err = app.SharedState().GetJSON("key", &Map{})
139 require.False(t, found)
140 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
141 _, found, err = app.SharedState().GetMsgPack("key", &Map{})
142 require.False(t, found)
143 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
144 _, found, err = app.SharedState().GetCBOR("key", &Map{})
145 require.False(t, found)
146 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
147 _, found, err = app.SharedState().GetXML("key", &Map{})
148 require.False(t, found)
149 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
150
151 err = app.SharedState().Delete("key")
152 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
153
154 has, err := app.SharedState().Has("key")
155 require.False(t, has)
156 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
157
158 err = app.SharedState().Reset()
159 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
160
161 err = app.SharedState().Close()
162 require.ErrorIs(t, err, ErrSharedStorageNotConfigured)
163}
164
165func TestSharedState_PreforkSafeWithSharedStorage(t *testing.T) {
166 t.Parallel()

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
ResetMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected