Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-10 10:20:21 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-14 09:54:12 +0300
commit9731244a9e5e53d8d469ca9ca8b0fac5049a2e21 (patch)
tree3f92ef4f1ca21c6f6845bc449de1de18858f2022
parent96d719812d67df232017eb4dbac800d575d3c88d (diff)
testhelper: Drop cancel function from context options
There are no context options anymore which would set up a separate way to cancel the context given that deadlines and similar things are forbidden nowadays. As a result, the `func()` return value of context options isn't used at all anymore. Simplify context creation by dropping the cancel function from context options.
-rw-r--r--internal/testhelper/testhelper.go19
1 files changed, 6 insertions, 13 deletions
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index b5b008ff8..f9f3656fd 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -157,12 +157,12 @@ func GetLocalhostListener(t testing.TB) (net.Listener, string) {
}
// ContextOpt returns a new context instance with the new additions to it.
-type ContextOpt func(context.Context) (context.Context, func())
+type ContextOpt func(context.Context) context.Context
// ContextWithLogger allows to inject provided logger into the context.
func ContextWithLogger(logger *log.Entry) ContextOpt {
- return func(ctx context.Context) (context.Context, func()) {
- return ctxlogrus.ToContext(ctx, logger), func() {}
+ return func(ctx context.Context) context.Context {
+ return ctxlogrus.ToContext(ctx, logger)
}
}
@@ -180,18 +180,11 @@ func Context(opts ...ContextOpt) (context.Context, func()) {
// context.
ctx = featureflag.ContextWithFeatureFlags(ctx, featureflag.RunCommandsInCGroup)
- cancels := make([]func(), len(opts)+1)
- cancels[0] = cancel
- for i, opt := range opts {
- ctx, cancel = opt(ctx)
- cancels[i+1] = cancel
+ for _, opt := range opts {
+ ctx = opt(ctx)
}
- return ctx, func() {
- for i := len(cancels) - 1; i >= 0; i-- {
- cancels[i]()
- }
- }
+ return ctx, cancel
}
// CreateGlobalDirectory creates a directory in the test directory that is shared across all