1package componenttest 2 3import ( 4 "context" 5 "testing" 6) 7 8// TestContext returns a context which cancels itself when t finishes. 9func TestContext(t *testing.T) context.Context { 10 ctx, cancel := context.WithCancel(context.Background()) 11 t.Cleanup(cancel) 12 return ctx 13} 14 15