Clean up some lint errors that we missed before.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer
2020-08-04 20:45:03 -05:00
parent 6da420d865
commit 519484816d
3 changed files with 13 additions and 10 deletions

View File

@@ -124,7 +124,7 @@ func ExchangeToken(ctx context.Context, token, caBundle, apiEndpoint string) (*C
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusCreated {
return nil, fmt.Errorf("could not login: server returned status %d", resp.StatusCode)
return nil, fmt.Errorf("%w: server returned status %d", ErrLoginFailed, resp.StatusCode)
}
var respBody struct {

View File

@@ -72,6 +72,7 @@ func TestExchangeToken(t *testing.T) {
// Start a test server that doesn't do anything.
caBundle, endpoint := startTestServer(t, func(w http.ResponseWriter, r *http.Request) {})
//nolint:staticcheck // ignore "do not pass a nil Context" linter error since that's what we're testing here.
got, err := ExchangeToken(nil, "", caBundle, endpoint)
require.EqualError(t, err, `could not build request: net/http: nil Context`)
require.Nil(t, got)
@@ -86,7 +87,7 @@ func TestExchangeToken(t *testing.T) {
})
got, err := ExchangeToken(ctx, "", caBundle, endpoint)
require.EqualError(t, err, `could not login: server returned status 500`)
require.EqualError(t, err, `login failed: server returned status 500`)
require.Nil(t, got)
})