TFromContext returns the *testing.T saved using ContextWithTB from the context.
(ctx context.Context)
| 47 | |
| 48 | // TFromContext returns the *testing.T saved using ContextWithTB from the context. |
| 49 | func TFromContext(ctx context.Context) (*testing.T, bool) { |
| 50 | t, ok := ctx.Value(tbKey{}).(*testing.T) |
| 51 | if !ok { |
| 52 | return nil, false |
| 53 | } |
| 54 | return t, true |
| 55 | } |
| 56 | |
| 57 | // MustTFromContext returns the *testing.T from the context, and panics if it was not saved in the context. |
| 58 | func MustTFromContext(ctx context.Context) *testing.T { |
no test coverage detected