Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
|
| 13 | 13 |
"github.com/docker/docker/api/types/versions" |
| 14 | 14 |
"github.com/docker/docker/testutil/request" |
| 15 |
+ "github.com/pkg/errors" |
|
| 15 | 16 |
"gotest.tools/assert" |
| 16 | 17 |
) |
| 17 | 18 |
|
| ... | ... |
@@ -46,7 +47,7 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
|
| 46 | 46 |
return err |
| 47 | 47 |
} |
| 48 | 48 |
if res.StatusCode != http.StatusCreated {
|
| 49 |
- return fmt.Errorf("POST %s is expected to return %d, got %d", uri, http.StatusCreated, res.StatusCode)
|
|
| 49 |
+ return errors.Errorf("POST %s is expected to return %d, got %d", uri, http.StatusCreated, res.StatusCode)
|
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
buf, err := request.ReadBody(body) |
| ... | ... |
@@ -55,18 +56,18 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
|
| 55 | 55 |
out := map[string]string{}
|
| 56 | 56 |
err = json.Unmarshal(buf, &out) |
| 57 | 57 |
if err != nil {
|
| 58 |
- return fmt.Errorf("ExecCreate returned invalid json. Error: %q", err.Error())
|
|
| 58 |
+ return errors.Wrap(err, "ExecCreate returned invalid json") |
|
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 | 61 |
execID := out["Id"] |
| 62 | 62 |
if len(execID) < 1 {
|
| 63 |
- return fmt.Errorf("ExecCreate got invalid execID")
|
|
| 63 |
+ return errors.New("ExecCreate got invalid execID")
|
|
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 | 66 |
payload := bytes.NewBufferString(`{"Tty":true}`)
|
| 67 | 67 |
conn, _, err := sockRequestHijack("POST", fmt.Sprintf("/exec/%s/start", execID), payload, "application/json", request.DaemonHost())
|
| 68 | 68 |
if err != nil {
|
| 69 |
- return fmt.Errorf("Failed to start the exec: %q", err.Error())
|
|
| 69 |
+ return errors.Wrap(err, "failed to start the exec") |
|
| 70 | 70 |
} |
| 71 | 71 |
defer conn.Close() |
| 72 | 72 |
|
| ... | ... |
@@ -74,10 +75,10 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
|
| 74 | 74 |
if err != nil {
|
| 75 | 75 |
// It's probably a panic of the daemon if io.ErrUnexpectedEOF is returned. |
| 76 | 76 |
if err == io.ErrUnexpectedEOF {
|
| 77 |
- return fmt.Errorf("The daemon might have crashed.")
|
|
| 77 |
+ return errors.New("the daemon might have crashed")
|
|
| 78 | 78 |
} |
| 79 | 79 |
// Other error happened, should be reported. |
| 80 |
- return fmt.Errorf("Fail to exec resize immediately after start. Error: %q", err.Error())
|
|
| 80 |
+ return errors.Wrap(err, "failed to exec resize immediately after start") |
|
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
rc.Close() |
| ... | ... |
@@ -173,33 +173,33 @@ func assertPortList(c *testing.T, out string, expected []string) error {
|
| 173 | 173 |
return nil |
| 174 | 174 |
} |
| 175 | 175 |
|
| 176 |
-func assertPortRange(c *testing.T, out string, expectedTcp, expectedUdp []int) error {
|
|
| 176 |
+func assertPortRange(c *testing.T, out string, expectedTCP, expectedUDP []int) error {
|
|
| 177 | 177 |
lines := strings.Split(strings.Trim(out, "\n "), "\n") |
| 178 | 178 |
|
| 179 |
- var validTcp, validUdp bool |
|
| 179 |
+ var validTCP, validUDP bool |
|
| 180 | 180 |
for _, l := range lines {
|
| 181 | 181 |
// 80/tcp -> 0.0.0.0:8015 |
| 182 | 182 |
port, err := strconv.Atoi(strings.Split(l, ":")[1]) |
| 183 | 183 |
if err != nil {
|
| 184 | 184 |
return err |
| 185 | 185 |
} |
| 186 |
- if strings.Contains(l, "tcp") && expectedTcp != nil {
|
|
| 187 |
- if port < expectedTcp[0] || port > expectedTcp[1] {
|
|
| 188 |
- return fmt.Errorf("tcp port (%d) not in range expected range %d-%d", port, expectedTcp[0], expectedTcp[1])
|
|
| 186 |
+ if strings.Contains(l, "tcp") && expectedTCP != nil {
|
|
| 187 |
+ if port < expectedTCP[0] || port > expectedTCP[1] {
|
|
| 188 |
+ return fmt.Errorf("tcp port (%d) not in range expected range %d-%d", port, expectedTCP[0], expectedTCP[1])
|
|
| 189 | 189 |
} |
| 190 |
- validTcp = true |
|
| 190 |
+ validTCP = true |
|
| 191 | 191 |
} |
| 192 |
- if strings.Contains(l, "udp") && expectedUdp != nil {
|
|
| 193 |
- if port < expectedUdp[0] || port > expectedUdp[1] {
|
|
| 194 |
- return fmt.Errorf("udp port (%d) not in range expected range %d-%d", port, expectedUdp[0], expectedUdp[1])
|
|
| 192 |
+ if strings.Contains(l, "udp") && expectedUDP != nil {
|
|
| 193 |
+ if port < expectedUDP[0] || port > expectedUDP[1] {
|
|
| 194 |
+ return fmt.Errorf("udp port (%d) not in range expected range %d-%d", port, expectedUDP[0], expectedUDP[1])
|
|
| 195 | 195 |
} |
| 196 |
- validUdp = true |
|
| 196 |
+ validUDP = true |
|
| 197 | 197 |
} |
| 198 | 198 |
} |
| 199 |
- if !validTcp {
|
|
| 199 |
+ if !validTCP {
|
|
| 200 | 200 |
return fmt.Errorf("tcp port not found")
|
| 201 | 201 |
} |
| 202 |
- if !validUdp {
|
|
| 202 |
+ if !validUDP {
|
|
| 203 | 203 |
return fmt.Errorf("udp port not found")
|
| 204 | 204 |
} |
| 205 | 205 |
return nil |