Skip to content

Commit 7f5bb1e

Browse files
committed
modernize: testingcontext
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest modernize -testingcontext -fix ./... Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 2875e48 commit 7f5bb1e

3 files changed

Lines changed: 6 additions & 12 deletions

File tree

cli/command/container/signals_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import (
1111
)
1212

1313
func TestForwardSignals(t *testing.T) {
14-
ctx, cancel := context.WithCancel(context.Background())
15-
defer cancel()
14+
ctx := t.Context()
1615

1716
called := make(chan struct{})
1817
apiClient := &fakeClient{containerKillFunc: func(ctx context.Context, container string, options client.ContainerKillOptions) (client.ContainerKillResult, error) {

cmd/docker/builder_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import (
2222
var pluginFilename = "docker-buildx"
2323

2424
func TestBuildWithBuilder(t *testing.T) {
25-
ctx, cancel := context.WithCancel(context.TODO())
26-
defer cancel()
25+
ctx := t.Context()
2726

2827
testcases := []struct {
2928
name string
@@ -131,8 +130,7 @@ func (*fakeClient) Ping(context.Context, client.PingOptions) (client.PingResult,
131130
}
132131

133132
func TestBuildkitDisabled(t *testing.T) {
134-
ctx, cancel := context.WithCancel(context.TODO())
135-
defer cancel()
133+
ctx := t.Context()
136134

137135
t.Setenv("DOCKER_BUILDKIT", "0")
138136

@@ -172,8 +170,7 @@ func TestBuildkitDisabled(t *testing.T) {
172170
}
173171

174172
func TestBuilderBroken(t *testing.T) {
175-
ctx, cancel := context.WithCancel(context.TODO())
176-
defer cancel()
173+
ctx := t.Context()
177174

178175
dir := fs.NewDir(t, t.Name(),
179176
fs.WithFile(pluginFilename, `#!/bin/sh exit 1`, fs.WithMode(0o777)),
@@ -212,8 +209,7 @@ func TestBuilderBroken(t *testing.T) {
212209

213210
func TestBuilderBrokenEnforced(t *testing.T) {
214211
t.Setenv("DOCKER_BUILDKIT", "1")
215-
ctx, cancel := context.WithCancel(context.TODO())
216-
defer cancel()
212+
ctx := t.Context()
217213

218214
dir := fs.NewDir(t, t.Name(),
219215
fs.WithFile(pluginFilename, `#!/bin/sh exit 1`, fs.WithMode(0o777)),

cmd/docker/docker_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ func TestDisableFlagsInUseLineIsSet(t *testing.T) {
3838

3939
func TestClientDebugEnabled(t *testing.T) {
4040
defer debug.Disable()
41-
ctx, cancel := context.WithCancel(context.TODO())
42-
defer cancel()
41+
ctx := t.Context()
4342

4443
cli, err := command.NewDockerCli(command.WithBaseContext(ctx))
4544
assert.NilError(t, err)

0 commit comments

Comments
 (0)