Enable linter bodyclose (#1968)

## Changes
Enable linter '[bodyclose](https://github.com/timakin/bodyclose)' and
fix 2 cases in tests.

## Tests
Existing tests.
This commit is contained in:
Denis Bilenko 2024-12-05 20:11:49 +01:00 committed by GitHub
parent 62bc59a3a6
commit 4c1042132b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,7 @@
linters:
disable-all: true
enable:
- bodyclose
# errcheck and govet are part of default setup and should be included but give too many errors now
# once errors are fixed, they should be enabled here:
#- errcheck

View File

@ -15,6 +15,7 @@ import (
"github.com/databricks/databricks-sdk-go/httpclient/fixtures"
"github.com/databricks/databricks-sdk-go/qa"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/oauth2"
)
@ -182,7 +183,8 @@ func TestChallenge(t *testing.T) {
state := <-browserOpened
resp, err := http.Get(fmt.Sprintf("http://%s?code=__THIS__&state=%s", appRedirectAddr, state))
assert.NoError(t, err)
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, 200, resp.StatusCode)
err = <-errc
@ -221,7 +223,8 @@ func TestChallengeFailed(t *testing.T) {
resp, err := http.Get(fmt.Sprintf(
"http://%s?error=access_denied&error_description=Policy%%20evaluation%%20failed%%20for%%20this%%20request",
appRedirectAddr))
assert.NoError(t, err)
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, 400, resp.StatusCode)
err = <-errc