From 334ecf0482cd48f52ed94ed8b2a57bbe6651c537 Mon Sep 17 00:00:00 2001 From: justin-slowik Date: Wed, 8 Jul 2020 16:36:52 -0400 Subject: [PATCH] Fixes based on PR comments. Signed-off-by: justin-slowik --- server/deviceflowhandlers_test.go | 16 ++++++++-------- server/server_test.go | 3 --- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/server/deviceflowhandlers_test.go b/server/deviceflowhandlers_test.go index 6d1ed7e3..f82b15db 100644 --- a/server/deviceflowhandlers_test.go +++ b/server/deviceflowhandlers_test.go @@ -61,7 +61,7 @@ func TestHandleDeviceCode(t *testing.T) { }, } for _, tc := range tests { - func() { + t.Run(tc.testName, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -105,7 +105,7 @@ func TestHandleDeviceCode(t *testing.T) { if tc.expectedResponseCode == http.StatusBadRequest || tc.expectedResponseCode == http.StatusUnauthorized { expectErrorResponse(tc.testName, body, tc.expectedServerResponse, t) } - }() + }) } } @@ -310,7 +310,7 @@ func TestDeviceCallback(t *testing.T) { }, } for _, tc := range tests { - func() { + t.Run(tc.testName, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -360,7 +360,7 @@ func TestDeviceCallback(t *testing.T) { if rr.Code != tc.expectedResponseCode { t.Errorf("%s: Unexpected Response Type. Expected %v got %v", tc.testName, tc.expectedResponseCode, rr.Code) } - }() + }) } } @@ -494,7 +494,7 @@ func TestDeviceTokenResponse(t *testing.T) { }, } for _, tc := range tests { - func() { + t.Run(tc.testName, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -544,7 +544,7 @@ func TestDeviceTokenResponse(t *testing.T) { } else if string(body) != tc.expectedServerResponse { t.Errorf("Unexpected Server Response. Expected %v got %v", tc.expectedServerResponse, string(body)) } - }() + }) } } @@ -625,7 +625,7 @@ func TestVerifyCodeResponse(t *testing.T) { }, } for _, tc := range tests { - func() { + t.Run(tc.testName, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -667,6 +667,6 @@ func TestVerifyCodeResponse(t *testing.T) { if rr.Code == http.StatusFound && !strings.HasPrefix(location, u.Path) { t.Errorf("Invalid Redirect. Expected %v got %v", u.Path, location) } - }() + }) } } diff --git a/server/server_test.go b/server/server_test.go index 8b0447fe..114d1fc8 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -1337,9 +1337,6 @@ func TestOAuth2DeviceFlow(t *testing.T) { data := url.Values{} data.Set("client_id", clientID) data.Add("scope", strings.Join(requestedScopes, " ")) - //for _, scope := range requestedScopes { - // data.Add("scope", scope) - //} resp, err := http.PostForm(codeURL.String(), data) if err != nil { t.Errorf("Could not request device code: %v", err)