Fixes based on PR comments.

Signed-off-by: justin-slowik <justin.slowik@thermofisher.com>
This commit is contained in:
justin-slowik 2020-07-08 16:36:52 -04:00
parent 1ea2892b79
commit 334ecf0482
2 changed files with 8 additions and 11 deletions

View file

@ -61,7 +61,7 @@ func TestHandleDeviceCode(t *testing.T) {
}, },
} }
for _, tc := range tests { for _, tc := range tests {
func() { t.Run(tc.testName, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@ -105,7 +105,7 @@ func TestHandleDeviceCode(t *testing.T) {
if tc.expectedResponseCode == http.StatusBadRequest || tc.expectedResponseCode == http.StatusUnauthorized { if tc.expectedResponseCode == http.StatusBadRequest || tc.expectedResponseCode == http.StatusUnauthorized {
expectErrorResponse(tc.testName, body, tc.expectedServerResponse, t) expectErrorResponse(tc.testName, body, tc.expectedServerResponse, t)
} }
}() })
} }
} }
@ -310,7 +310,7 @@ func TestDeviceCallback(t *testing.T) {
}, },
} }
for _, tc := range tests { for _, tc := range tests {
func() { t.Run(tc.testName, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@ -360,7 +360,7 @@ func TestDeviceCallback(t *testing.T) {
if rr.Code != tc.expectedResponseCode { if rr.Code != tc.expectedResponseCode {
t.Errorf("%s: Unexpected Response Type. Expected %v got %v", tc.testName, tc.expectedResponseCode, rr.Code) 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 { for _, tc := range tests {
func() { t.Run(tc.testName, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@ -544,7 +544,7 @@ func TestDeviceTokenResponse(t *testing.T) {
} else if string(body) != tc.expectedServerResponse { } else if string(body) != tc.expectedServerResponse {
t.Errorf("Unexpected Server Response. Expected %v got %v", tc.expectedServerResponse, string(body)) 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 { for _, tc := range tests {
func() { t.Run(tc.testName, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@ -667,6 +667,6 @@ func TestVerifyCodeResponse(t *testing.T) {
if rr.Code == http.StatusFound && !strings.HasPrefix(location, u.Path) { if rr.Code == http.StatusFound && !strings.HasPrefix(location, u.Path) {
t.Errorf("Invalid Redirect. Expected %v got %v", u.Path, location) t.Errorf("Invalid Redirect. Expected %v got %v", u.Path, location)
} }
}() })
} }
} }

View file

@ -1337,9 +1337,6 @@ func TestOAuth2DeviceFlow(t *testing.T) {
data := url.Values{} data := url.Values{}
data.Set("client_id", clientID) data.Set("client_id", clientID)
data.Add("scope", strings.Join(requestedScopes, " ")) data.Add("scope", strings.Join(requestedScopes, " "))
//for _, scope := range requestedScopes {
// data.Add("scope", scope)
//}
resp, err := http.PostForm(codeURL.String(), data) resp, err := http.PostForm(codeURL.String(), data)
if err != nil { if err != nil {
t.Errorf("Could not request device code: %v", err) t.Errorf("Could not request device code: %v", err)