소스 검색

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 5 년 전
부모
커밋
b639f933e1
2개의 변경된 파일19개의 추가작업 그리고 18개의 파일을 삭제
  1. 7 6
      integration-cli/docker_api_exec_resize_test.go
  2. 12 12
      integration-cli/docker_cli_port_test.go

+ 7 - 6
integration-cli/docker_api_exec_resize_test.go

@@ -12,6 +12,7 @@ import (
 
 	"github.com/docker/docker/api/types/versions"
 	"github.com/docker/docker/testutil/request"
+	"github.com/pkg/errors"
 	"gotest.tools/assert"
 )
 
@@ -46,7 +47,7 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
 			return err
 		}
 		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)
@@ -55,18 +56,18 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
 		out := map[string]string{}
 		err = json.Unmarshal(buf, &out)
 		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"]
 		if len(execID) < 1 {
-			return fmt.Errorf("ExecCreate got invalid execID")
+			return errors.New("ExecCreate got invalid execID")
 		}
 
 		payload := bytes.NewBufferString(`{"Tty":true}`)
 		conn, _, err := sockRequestHijack("POST", fmt.Sprintf("/exec/%s/start", execID), payload, "application/json", request.DaemonHost())
 		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()
 
@@ -74,10 +75,10 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
 		if err != nil {
 			// It's probably a panic of the daemon if io.ErrUnexpectedEOF is returned.
 			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.
-			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()

+ 12 - 12
integration-cli/docker_cli_port_test.go

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