MCPcopy
hub / github.com/pocketbase/pocketbase / TestValidateWithContext

Function TestValidateWithContext

core/db_test.go:78–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func TestValidateWithContext(t *testing.T) {
79 t.Parallel()
80
81 app, _ := tests.NewTestApp()
82 defer app.Cleanup()
83
84 u := &mockSuperusers{}
85
86 testErr := errors.New("test")
87
88 app.OnModelValidate().BindFunc(func(e *core.ModelEvent) error {
89 if v := e.Context.Value("test"); v != 123 {
90 t.Fatalf("Expected 'test' context value %#v, got %#v", 123, v)
91 }
92 return testErr
93 })
94
95 //nolint:staticcheck
96 ctx := context.WithValue(context.Background(), "test", 123)
97
98 err := app.ValidateWithContext(ctx, u)
99 if err != testErr {
100 t.Fatalf("Expected error %v, got %v", testErr, err)
101 }
102}
103
104// -------------------------------------------------------------------
105

Callers

nothing calls this directly

Calls 6

CleanupMethod · 0.95
NewTestAppFunction · 0.92
OnModelValidateMethod · 0.65
ValidateWithContextMethod · 0.65
BindFuncMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…