test: use cancelation from ktesting
The return type of ktesting.NewTestContext is now a TContext. Code which combined it WithCancel often didn't compile anymore (cannot overwrite ktesting.TContext with context.Context). This is a good thing because all of that code can be simplified to let ktesting handle the cancelation.
This commit is contained in:
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package ktesting
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"testing"
|
||||
@@ -41,14 +40,9 @@ func SetDefaultVerbosity(v int) {
|
||||
_ = f.Value.Set(fmt.Sprintf("%d", v))
|
||||
}
|
||||
|
||||
// NewTestContext is a drop-in replacement for ktesting.NewTestContext
|
||||
// NewTestContext is a replacement for ktesting.NewTestContext
|
||||
// which returns a more versatile context.
|
||||
//
|
||||
// The type of that context is still context.Context because replacing
|
||||
// it with TContext breaks tests which use `WithCancel`.
|
||||
//
|
||||
// TODO(pohly): change all of that code together with changing the return type.
|
||||
func NewTestContext(tb testing.TB) (klog.Logger, context.Context) {
|
||||
func NewTestContext(tb testing.TB) (klog.Logger, TContext) {
|
||||
tCtx := Init(tb)
|
||||
return tCtx.Logger(), tCtx
|
||||
}
|
||||
|
Reference in New Issue
Block a user