tests: cleanup table test names

There's no need for `case=[xxx]` in table tests, Go does a good job of
formatting the test output and we're just adding the same information
for every test output line.

Previously:
```console
$ go test -count=1 -v -run=TestPromptForConfirmation ./cli/command
=== RUN   TestPromptForConfirmation
=== RUN   TestPromptForConfirmation/case=SIGINT
=== RUN   TestPromptForConfirmation/case=no
=== RUN   TestPromptForConfirmation/case=yes
=== RUN   TestPromptForConfirmation/case=any
=== RUN   TestPromptForConfirmation/case=with_space
=== RUN   TestPromptForConfirmation/case=reader_closed
--- PASS: TestPromptForConfirmation (0.00s)
    --- PASS: TestPromptForConfirmation/case=SIGINT (0.00s)
    --- PASS: TestPromptForConfirmation/case=no (0.00s)
    --- PASS: TestPromptForConfirmation/case=yes (0.00s)
    --- PASS: TestPromptForConfirmation/case=any (0.00s)
    --- PASS: TestPromptForConfirmation/case=with_space (0.00s)
    --- PASS: TestPromptForConfirmation/case=reader_closed (0.00s)
PASS
ok      github.com/docker/cli/cli/command       0.013s
```

After:
```console
go test -count=1 -v -run=TestPromptForConfirmation ./cli/command
=== RUN   TestPromptForConfirmation
=== RUN   TestPromptForConfirmation/SIGINT
=== RUN   TestPromptForConfirmation/no
=== RUN   TestPromptForConfirmation/yes
=== RUN   TestPromptForConfirmation/any
=== RUN   TestPromptForConfirmation/with_space
=== RUN   TestPromptForConfirmation/reader_closed
--- PASS: TestPromptForConfirmation (0.00s)
    --- PASS: TestPromptForConfirmation/SIGINT (0.00s)
    --- PASS: TestPromptForConfirmation/no (0.00s)
    --- PASS: TestPromptForConfirmation/yes (0.00s)
    --- PASS: TestPromptForConfirmation/any (0.00s)
    --- PASS: TestPromptForConfirmation/with_space (0.00s)
    --- PASS: TestPromptForConfirmation/reader_closed (0.00s)
PASS
ok      github.com/docker/cli/cli/command       0.009s
```

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
Laura Brehm 2024-11-27 16:42:38 +00:00
parent ba1a15433b
commit 1d4a7ae082
No known key found for this signature in database
GPG Key ID: 08EC1B0491948487
2 changed files with 4 additions and 4 deletions

View File

@ -82,7 +82,7 @@ func TestValidateOutputPath(t *testing.T) {
} }
func TestPromptForInput(t *testing.T) { func TestPromptForInput(t *testing.T) {
t.Run("case=cancelling the context", func(t *testing.T) { t.Run("cancelling the context", func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel) t.Cleanup(cancel)
reader, _ := io.Pipe() reader, _ := io.Pipe()
@ -116,7 +116,7 @@ func TestPromptForInput(t *testing.T) {
} }
}) })
t.Run("case=user input should be properly trimmed", func(t *testing.T) { t.Run("user input should be properly trimmed", func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
t.Cleanup(cancel) t.Cleanup(cancel)
@ -196,7 +196,7 @@ func TestPromptForConfirmation(t *testing.T) {
return promptReader.Close() return promptReader.Close()
}, promptResult{false, nil}}, }, promptResult{false, nil}},
} { } {
t.Run("case="+tc.desc, func(t *testing.T) { t.Run(tc.desc, func(t *testing.T) {
notifyCtx, notifyCancel := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM) notifyCtx, notifyCancel := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM)
t.Cleanup(notifyCancel) t.Cleanup(notifyCancel)

View File

@ -182,7 +182,7 @@ func TestPromptExitCode(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
t.Run("case="+tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
buf := new(bytes.Buffer) buf := new(bytes.Buffer)