mirror of
https://github.com/outbackdingo/kubernetes.git
synced 2026-01-27 10:19:35 +00:00
ktesting: add WithoutCancel
This closes a gap compared to the context package. It's useful when combined with Ginkgo to keep something running beyond the end of the Ginkgo BeforeEach or It node.
This commit is contained in:
@@ -43,6 +43,13 @@ func WithCancel(tCtx TContext) TContext {
|
||||
}
|
||||
}
|
||||
|
||||
// WithoutCancel causes the returned context to ignore cancellation of its parent.
|
||||
func WithoutCancel(tCtx TContext) TContext {
|
||||
tCtx.Helper()
|
||||
ctx := context.WithoutCancel(tCtx)
|
||||
return WithContext(tCtx, ctx)
|
||||
}
|
||||
|
||||
// WithTimeout sets up new context with a timeout. Canceling the timeout gets
|
||||
// registered in a [TContext.Cleanup] callback. [TContext.Cancel] cancels only
|
||||
// the new context. The cause is used as reason why the context is canceled
|
||||
|
||||
Reference in New Issue
Block a user