integration-cli: fix capitalization of variables and errors (golint)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-08-05 15:17:42 +02:00
parent 07ff4f1de8
commit b639f933e1
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 19 additions and 18 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/testutil/request" "github.com/docker/docker/testutil/request"
"github.com/pkg/errors"
"gotest.tools/assert" "gotest.tools/assert"
) )
@ -46,7 +47,7 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
return err return err
} }
if res.StatusCode != http.StatusCreated { if res.StatusCode != http.StatusCreated {
return fmt.Errorf("POST %s is expected to return %d, got %d", uri, http.StatusCreated, res.StatusCode) return errors.Errorf("POST %s is expected to return %d, got %d", uri, http.StatusCreated, res.StatusCode)
} }
buf, err := request.ReadBody(body) buf, err := request.ReadBody(body)
@ -55,18 +56,18 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
out := map[string]string{} out := map[string]string{}
err = json.Unmarshal(buf, &out) err = json.Unmarshal(buf, &out)
if err != nil { if err != nil {
return fmt.Errorf("ExecCreate returned invalid json. Error: %q", err.Error()) return errors.Wrap(err, "ExecCreate returned invalid json")
} }
execID := out["Id"] execID := out["Id"]
if len(execID) < 1 { if len(execID) < 1 {
return fmt.Errorf("ExecCreate got invalid execID") return errors.New("ExecCreate got invalid execID")
} }
payload := bytes.NewBufferString(`{"Tty":true}`) payload := bytes.NewBufferString(`{"Tty":true}`)
conn, _, err := sockRequestHijack("POST", fmt.Sprintf("/exec/%s/start", execID), payload, "application/json", request.DaemonHost()) conn, _, err := sockRequestHijack("POST", fmt.Sprintf("/exec/%s/start", execID), payload, "application/json", request.DaemonHost())
if err != nil { if err != nil {
return fmt.Errorf("Failed to start the exec: %q", err.Error()) return errors.Wrap(err, "failed to start the exec")
} }
defer conn.Close() defer conn.Close()
@ -74,10 +75,10 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
if err != nil { if err != nil {
// It's probably a panic of the daemon if io.ErrUnexpectedEOF is returned. // It's probably a panic of the daemon if io.ErrUnexpectedEOF is returned.
if err == io.ErrUnexpectedEOF { if err == io.ErrUnexpectedEOF {
return fmt.Errorf("The daemon might have crashed.") return errors.New("the daemon might have crashed")
} }
// Other error happened, should be reported. // Other error happened, should be reported.
return fmt.Errorf("Fail to exec resize immediately after start. Error: %q", err.Error()) return errors.Wrap(err, "failed to exec resize immediately after start")
} }
rc.Close() rc.Close()

View File

@ -173,33 +173,33 @@ func assertPortList(c *testing.T, out string, expected []string) error {
return nil return nil
} }
func assertPortRange(c *testing.T, out string, expectedTcp, expectedUdp []int) error { func assertPortRange(c *testing.T, out string, expectedTCP, expectedUDP []int) error {
lines := strings.Split(strings.Trim(out, "\n "), "\n") lines := strings.Split(strings.Trim(out, "\n "), "\n")
var validTcp, validUdp bool var validTCP, validUDP bool
for _, l := range lines { for _, l := range lines {
// 80/tcp -> 0.0.0.0:8015 // 80/tcp -> 0.0.0.0:8015
port, err := strconv.Atoi(strings.Split(l, ":")[1]) port, err := strconv.Atoi(strings.Split(l, ":")[1])
if err != nil { if err != nil {
return err return err
} }
if strings.Contains(l, "tcp") && expectedTcp != nil { if strings.Contains(l, "tcp") && expectedTCP != nil {
if port < expectedTcp[0] || port > expectedTcp[1] { if port < expectedTCP[0] || port > expectedTCP[1] {
return fmt.Errorf("tcp port (%d) not in range expected range %d-%d", port, expectedTcp[0], expectedTcp[1]) return fmt.Errorf("tcp port (%d) not in range expected range %d-%d", port, expectedTCP[0], expectedTCP[1])
} }
validTcp = true validTCP = true
} }
if strings.Contains(l, "udp") && expectedUdp != nil { if strings.Contains(l, "udp") && expectedUDP != nil {
if port < expectedUdp[0] || port > expectedUdp[1] { if port < expectedUDP[0] || port > expectedUDP[1] {
return fmt.Errorf("udp port (%d) not in range expected range %d-%d", port, expectedUdp[0], expectedUdp[1]) return fmt.Errorf("udp port (%d) not in range expected range %d-%d", port, expectedUDP[0], expectedUDP[1])
} }
validUdp = true validUDP = true
} }
} }
if !validTcp { if !validTCP {
return fmt.Errorf("tcp port not found") return fmt.Errorf("tcp port not found")
} }
if !validUdp { if !validUDP {
return fmt.Errorf("udp port not found") return fmt.Errorf("udp port not found")
} }
return nil return nil