chore: cleanup tests · docker/cli@f4e617d · GitHub
Skip to content

Commit f4e617d

Browse files
committed
chore: cleanup tests
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
1 parent 4062944 commit f4e617d

14 files changed

Lines changed: 116 additions & 88 deletions

File tree

‎cli/command/builder/prune.go‎

Lines changed: 3 additions & 1 deletion

‎cli/command/builder/prune_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"testing"
7-
"time"
87

98
"github.com/docker/cli/internal/test"
109
"github.com/docker/docker/api/types"
@@ -19,8 +18,6 @@ func TestBuilderPromptTermination(t *testing.T) {
1918
return nil, errors.New("fakeClient builderPruneFunc should not be called")
2019
},
2120
})
22-
// set a fake reader so that our kill signal reaches the prompt before the prompt reads from stdin
23-
cli.SetIn(test.NewFakeStreamIn(ctx, time.Second*2))
2421
cmd := NewPruneCommand(cli)
2522
test.TerminatePrompt(ctx, t, cmd, cli, nil)
2623
}

‎cli/command/container/prune_test.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package container
33
import (
44
"context"
55
"testing"
6-
"time"
76

87
"github.com/docker/cli/internal/test"
98
"github.com/docker/docker/api/types"
@@ -20,9 +19,6 @@ func TestContainerPrunePromptTermination(t *testing.T) {
2019
return types.ContainersPruneReport{}, errors.New("fakeClient containerPruneFunc should not be called")
2120
},
2221
})
23-
24-
// set a fake reader so that our kill signal reaches the prompt before the prompt reads from stdin
25-
cli.SetIn(test.NewFakeStreamIn(ctx, time.Second*2))
2622
cmd := NewPruneCommand(cli)
2723
test.TerminatePrompt(ctx, t, cmd, cli, nil)
2824
}

‎cli/command/image/prune_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"io"
77
"testing"
8-
"time"
98

109
"github.com/docker/cli/internal/test"
1110
"github.com/docker/docker/api/types"
@@ -113,8 +112,6 @@ func TestPrunePromptTermination(t *testing.T) {
113112
return types.ImagesPruneReport{}, errors.New("fakeClient imagesPruneFunc should not be called")
114113
},
115114
})
116-
// set a fake reader so that our kill signal reaches the prompt before the prompt reads from stdin
117-
cli.SetIn(test.NewFakeStreamIn(ctx, time.Second*2))
118115
cmd := NewPruneCommand(cli)
119116
test.TerminatePrompt(ctx, t, cmd, cli, nil)
120117
}

‎cli/command/network/prune_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package network
33
import (
44
"context"
55
"testing"
6-
"time"
76

87
"github.com/docker/cli/internal/test"
98
"github.com/docker/docker/api/types"
@@ -20,8 +19,6 @@ func TestNetworkPrunePromptTermination(t *testing.T) {
2019
return types.NetworksPruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
2120
},
2221
})
23-
// set a fake reader so that our kill signal reaches the prompt before the prompt reads from stdin
24-
cli.SetIn(test.NewFakeStreamIn(ctx, time.Second*2))
2522
cmd := NewPruneCommand(cli)
2623
test.TerminatePrompt(ctx, t, cmd, cli, nil)
2724
}

‎cli/command/network/remove_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"io"
66
"testing"
7-
"time"
87

98
"github.com/docker/cli/internal/test"
109
"github.com/docker/docker/api/types"
@@ -113,8 +112,6 @@ func TestNetworkRemovePromptTermination(t *testing.T) {
113112
}, nil, nil
114113
},
115114
})
116-
// set a fake reader so that our kill signal reaches the prompt before the prompt reads from stdin
117-
cli.SetIn(test.NewFakeStreamIn(ctx, time.Second*2))
118115
cmd := newRemoveCommand(cli)
119116
cmd.SetArgs([]string{"existing-network"})
120117
test.TerminatePrompt(ctx, t, cmd, cli, nil)

‎cli/command/plugin/upgrade_test.go‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"io"
66
"testing"
7-
"time"
87

98
"github.com/docker/cli/internal/test"
109
"github.com/docker/docker/api/types"
@@ -14,9 +13,6 @@ import (
1413
)
1514

1615
func TestUpgradePromptTermination(t *testing.T) {
17-
t.Cleanup(func() {
18-
})
19-
2016
ctx, cancel := context.WithCancel(context.Background())
2117
t.Cleanup(cancel)
2218

@@ -33,7 +29,6 @@ func TestUpgradePromptTermination(t *testing.T) {
3329
}, []byte{}, nil
3430
},
3531
})
36-
cli.SetIn(test.NewFakeStreamIn(ctx, time.Second*2))
3732
cmd := newUpgradeCommand(cli)
3833
// need to set a remote address that does not match the plugin
3934
// reference sent by the `pluginInspectFunc`

‎cli/command/system/prune_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package system
33
import (
44
"context"
55
"testing"
6-
"time"
76

87
"github.com/docker/cli/cli/config/configfile"
98
"github.com/docker/cli/internal/test"
@@ -68,8 +67,6 @@ func TestSystemPrunePromptTermination(t *testing.T) {
6867
},
6968
})
7069

71-
// set a fake reader so that our kill signal reaches the prompt before the prompt reads from stdin
72-
cli.SetIn(test.NewFakeStreamIn(ctx, time.Second*2))
7370
cmd := newPruneCommand(cli)
7471
test.TerminatePrompt(ctx, t, cmd, cli, nil)
7572
}

‎cli/command/trust/revoke_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"io"
66
"testing"
7-
"time"
87

98
"github.com/docker/cli/cli/trust"
109
"github.com/docker/cli/internal/test"
@@ -157,10 +156,8 @@ func TestRevokeTrustPromptTermination(t *testing.T) {
157156
t.Cleanup(cancel)
158157

159158
cli := test.NewFakeCli(&fakeClient{})
160-
cli.SetIn(test.NewFakeStreamIn(ctx, 2*time.Second))
161159
cmd := newRevokeCommand(cli)
162160
cmd.SetArgs([]string{"example/trust-demo"})
163-
164161
test.TerminatePrompt(ctx, t, cmd, cli, nil)
165162
assert.Equal(t, cli.ErrBuffer().String(), "")
166163
golden.Assert(t, cli.OutBuffer().String(), "trust-revoke-prompt-termination.golden")

‎cli/command/utils_test.go‎

Lines changed: 69 additions & 12 deletions

0 commit comments

Comments
 (0)