mirror of
https://github.com/docker/compose.git
synced 2026-02-09 01:59:22 +08:00
test: replace context.Background()/context.TODO() with t.Context()
Replace manual context creation with t.Context() which is automatically cancelled when the test completes. Go 1.24 modernization pattern. Assisted-By: cagent Signed-off-by: David Gageot <david.gageot@docker.com>
This commit is contained in:
committed by
Guillaume Lours
parent
b92b87dd9c
commit
093205121c
@@ -17,7 +17,6 @@
|
||||
package desktop
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -34,9 +33,6 @@ func TestClientPing(t *testing.T) {
|
||||
t.Skip("Skipping - COMPOSE_TEST_DESKTOP_ENDPOINT not defined")
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
|
||||
client := NewClient(desktopEndpoint)
|
||||
t.Cleanup(func() {
|
||||
_ = client.Close()
|
||||
@@ -44,7 +40,7 @@ func TestClientPing(t *testing.T) {
|
||||
|
||||
now := time.Now()
|
||||
|
||||
ret, err := client.Ping(ctx)
|
||||
ret, err := client.Ping(t.Context())
|
||||
require.NoError(t, err)
|
||||
|
||||
serverTime := time.Unix(0, ret.ServerTime)
|
||||
|
||||
Reference in New Issue
Block a user