From 2ebbc0122ca33033fb13685bb8747f4d614492e9 Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Thu, 1 Aug 2024 12:34:33 +0100 Subject: [PATCH] tests: fix flaky `TestLoginDevice` test Signed-off-by: Laura Brehm --- cli/internal/oauth/manager/manager_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli/internal/oauth/manager/manager_test.go b/cli/internal/oauth/manager/manager_test.go index c5154960e2cc..1ca72c78536c 100644 --- a/cli/internal/oauth/manager/manager_test.go +++ b/cli/internal/oauth/manager/manager_test.go @@ -4,6 +4,7 @@ import ( "context" "os" "testing" + "time" "github.com/docker/cli/cli/internal/oauth/api" "github.com/docker/cli/cli/oauth" @@ -122,6 +123,8 @@ func TestLoginDevice(t *testing.T) { }, nil } waitForDeviceToken := func(state api.State) (api.TokenResponse, error) { + // make sure that the context is cancelled before this returns + time.Sleep(500 * time.Millisecond) return api.TokenResponse{ AccessToken: validToken, RefreshToken: "refresh-token",