(t *testing.T)
| 76 | } |
| 77 | |
| 78 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…