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

Function TestSharedState_RawWithContextVariants

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

Source from the content-addressed store, hash-verified

457}
458
459func TestSharedState_RawWithContextVariants(t *testing.T) {
460 t.Parallel()
461
462 type testContextKey string
463
464 ctxKey := testContextKey("tenant")
465 store := &contextCheckingStorage{ctxKey: ctxKey, base: newSharedStateMemoryStorage(t)}
466 app := New(Config{SharedStorage: store})
467
468 err := app.SharedState().SetWithContext(context.Background(), "raw", []byte("x"), time.Second)
469 require.Error(t, err)
470
471 ctx := context.WithValue(context.Background(), ctxKey, "value")
472 require.NoError(t, app.SharedState().SetWithContext(ctx, "raw", []byte("x"), time.Second))
473
474 raw, found, err := app.SharedState().GetWithContext(ctx, "raw")
475 require.NoError(t, err)
476 require.True(t, found)
477 require.Equal(t, []byte("x"), raw)
478}
479
480func TestSharedState_SetGet_RawDataKinds(t *testing.T) {
481 t.Parallel()

Callers

nothing calls this directly

Calls 7

SharedStateMethod · 0.80
testContextKeyTypeAlias · 0.70
NewFunction · 0.70
SetWithContextMethod · 0.65
ErrorMethod · 0.65
GetWithContextMethod · 0.65

Tested by

no test coverage detected