integration-cli: SA5001: should check returned error before deferring reg.Close() (staticcheck)

```
integration-cli/docker_cli_registry_user_agent_test.go:78:2: SA5001: should check returned error before deferring reg.Close() (staticcheck)
integration-cli/docker_cli_v2_only_test.go:30:2:             SA5001: should check returned error before deferring reg.Close() (staticcheck)
integration-cli/docker_api_containers_test.go:392:3:         SA5001: should check returned error before deferring resp.Body.Close() (staticcheck)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-08-28 19:56:38 +02:00
parent 40b3edc81e
commit 5bba06e082
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
3 changed files with 10 additions and 9 deletions

View File

@ -348,6 +348,7 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *testing.T) {
defer cli.Close()
resp, err := cli.ContainerStats(context.Background(), name, false)
assert.NilError(c, err)
defer resp.Body.Close()
chResp <- err
}()

View File

@ -75,8 +75,9 @@ func (s *DockerRegistrySuite) TestUserAgentPassThrough(c *testing.T) {
var ua string
reg, err := registry.NewMock(c)
defer reg.Close()
assert.NilError(c, err)
defer reg.Close()
registerUserAgentHandler(reg, &ua)
repoName := fmt.Sprintf("%s/busybox", reg.URL())

View File

@ -27,8 +27,8 @@ func makefile(path string, contents string) (string, error) {
// attempt to contact any v1 registry endpoints.
func (s *DockerRegistrySuite) TestV2Only(c *testing.T) {
reg, err := registry.NewMock(c)
defer reg.Close()
assert.NilError(c, err)
defer reg.Close()
reg.RegisterHandler("/v2/", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(404)
@ -49,11 +49,10 @@ func (s *DockerRegistrySuite) TestV2Only(c *testing.T) {
dockerfileName, err := makefile(tmp, fmt.Sprintf("FROM %s/busybox", reg.URL()))
assert.NilError(c, err, "Unable to create test dockerfile")
s.d.Cmd("build", "--file", dockerfileName, tmp)
s.d.Cmd("run", repoName)
s.d.Cmd("login", "-u", "richard", "-p", "testtest", reg.URL())
s.d.Cmd("tag", "busybox", repoName)
s.d.Cmd("push", repoName)
s.d.Cmd("pull", repoName)
_, _ = s.d.Cmd("build", "--file", dockerfileName, tmp)
_, _ = s.d.Cmd("run", repoName)
_, _ = s.d.Cmd("login", "-u", "richard", "-p", "testtest", reg.URL())
_, _ = s.d.Cmd("tag", "busybox", repoName)
_, _ = s.d.Cmd("push", repoName)
_, _ = s.d.Cmd("pull", repoName)
}