This was just an alias to `strings.TrimSpace`
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
... | ... |
@@ -3,6 +3,7 @@ package main |
3 | 3 |
import ( |
4 | 4 |
"bytes" |
5 | 5 |
"os/exec" |
6 |
+ "strings" |
|
6 | 7 |
"testing" |
7 | 8 |
"time" |
8 | 9 |
|
... | ... |
@@ -22,7 +23,7 @@ func TestGetContainersAttachWebsocket(t *testing.T) { |
22 | 22 |
t.Fatal(err) |
23 | 23 |
} |
24 | 24 |
|
25 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
25 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
26 | 26 |
config, err := websocket.NewConfig( |
27 | 27 |
"/containers/"+cleanedContainerID+"/attach/ws?stream=1&stdin=1&stdout=1&stderr=1", |
28 | 28 |
"http://localhost", |
... | ... |
@@ -3,6 +3,7 @@ package main |
3 | 3 |
import ( |
4 | 4 |
"encoding/json" |
5 | 5 |
"os/exec" |
6 |
+ "strings" |
|
6 | 7 |
"testing" |
7 | 8 |
) |
8 | 9 |
|
... | ... |
@@ -15,7 +16,7 @@ func TestInspectApiContainerResponse(t *testing.T) { |
15 | 15 |
t.Fatalf("failed to create a container: %s, %v", out, err) |
16 | 16 |
} |
17 | 17 |
|
18 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
18 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
19 | 19 |
|
20 | 20 |
// test on json marshal version |
21 | 21 |
// and latest version |
... | ... |
@@ -13,7 +13,7 @@ func TestResizeApiResponse(t *testing.T) { |
13 | 13 |
t.Fatalf(out, err) |
14 | 14 |
} |
15 | 15 |
defer deleteAllContainers() |
16 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
16 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
17 | 17 |
|
18 | 18 |
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" |
19 | 19 |
_, err = sockRequest("POST", endpoint, nil) |
... | ... |
@@ -31,7 +31,7 @@ func TestResizeApiResponseWhenContainerNotStarted(t *testing.T) { |
31 | 31 |
t.Fatalf(out, err) |
32 | 32 |
} |
33 | 33 |
defer deleteAllContainers() |
34 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
34 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
35 | 35 |
|
36 | 36 |
// make sure the exited cintainer is not running |
37 | 37 |
runCmd = exec.Command(dockerBinary, "wait", cleanedContainerID) |
... | ... |
@@ -492,7 +492,7 @@ func TestBuildOnBuildForbiddenMaintainerInSourceImage(t *testing.T) { |
492 | 492 |
t.Fatal(out, err) |
493 | 493 |
} |
494 | 494 |
|
495 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
495 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
496 | 496 |
|
497 | 497 |
commitCmd := exec.Command(dockerBinary, "commit", "--run", "{\"OnBuild\":[\"MAINTAINER docker.io\"]}", cleanedContainerID, "onbuild") |
498 | 498 |
|
... | ... |
@@ -526,7 +526,7 @@ func TestBuildOnBuildForbiddenFromInSourceImage(t *testing.T) { |
526 | 526 |
t.Fatal(out, err) |
527 | 527 |
} |
528 | 528 |
|
529 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
529 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
530 | 530 |
|
531 | 531 |
commitCmd := exec.Command(dockerBinary, "commit", "--run", "{\"OnBuild\":[\"FROM busybox\"]}", cleanedContainerID, "onbuild") |
532 | 532 |
|
... | ... |
@@ -560,7 +560,7 @@ func TestBuildOnBuildForbiddenChainedInSourceImage(t *testing.T) { |
560 | 560 |
t.Fatal(out, err) |
561 | 561 |
} |
562 | 562 |
|
563 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
563 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
564 | 564 |
|
565 | 565 |
commitCmd := exec.Command(dockerBinary, "commit", "--run", "{\"OnBuild\":[\"ONBUILD RUN ls\"]}", cleanedContainerID, "onbuild") |
566 | 566 |
|
... | ... |
@@ -5534,7 +5534,7 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) { |
5534 | 5534 |
t.Fatal(err, out) |
5535 | 5535 |
} |
5536 | 5536 |
|
5537 |
- cID := stripTrailingCharacters(out) |
|
5537 |
+ cID := strings.TrimSpace(out) |
|
5538 | 5538 |
|
5539 | 5539 |
type hostConfig struct { |
5540 | 5540 |
Memory float64 // Use float64 here since the json decoder sees it that way |
... | ... |
@@ -13,7 +13,7 @@ func TestCommitAfterContainerIsDone(t *testing.T) { |
13 | 13 |
t.Fatalf("failed to run container: %s, %v", out, err) |
14 | 14 |
} |
15 | 15 |
|
16 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
16 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
17 | 17 |
|
18 | 18 |
waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID) |
19 | 19 |
if _, _, err = runCommandWithOutput(waitCmd); err != nil { |
... | ... |
@@ -26,7 +26,7 @@ func TestCommitAfterContainerIsDone(t *testing.T) { |
26 | 26 |
t.Fatalf("failed to commit container to image: %s, %v", out, err) |
27 | 27 |
} |
28 | 28 |
|
29 |
- cleanedImageID := stripTrailingCharacters(out) |
|
29 |
+ cleanedImageID := strings.TrimSpace(out) |
|
30 | 30 |
|
31 | 31 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID) |
32 | 32 |
if out, _, err = runCommandWithOutput(inspectCmd); err != nil { |
... | ... |
@@ -46,7 +46,7 @@ func TestCommitWithoutPause(t *testing.T) { |
46 | 46 |
t.Fatalf("failed to run container: %s, %v", out, err) |
47 | 47 |
} |
48 | 48 |
|
49 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
49 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
50 | 50 |
|
51 | 51 |
waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID) |
52 | 52 |
if _, _, err = runCommandWithOutput(waitCmd); err != nil { |
... | ... |
@@ -59,7 +59,7 @@ func TestCommitWithoutPause(t *testing.T) { |
59 | 59 |
t.Fatalf("failed to commit container to image: %s, %v", out, err) |
60 | 60 |
} |
61 | 61 |
|
62 |
- cleanedImageID := stripTrailingCharacters(out) |
|
62 |
+ cleanedImageID := strings.TrimSpace(out) |
|
63 | 63 |
|
64 | 64 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID) |
65 | 65 |
if out, _, err = runCommandWithOutput(inspectCmd); err != nil { |
... | ... |
@@ -82,7 +82,7 @@ func TestCommitPausedContainer(t *testing.T) { |
82 | 82 |
t.Fatalf("failed to run container: %v, output: %q", err, out) |
83 | 83 |
} |
84 | 84 |
|
85 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
85 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
86 | 86 |
cmd = exec.Command(dockerBinary, "pause", cleanedContainerID) |
87 | 87 |
out, _, _, err = runCommandWithStdoutStderr(cmd) |
88 | 88 |
if err != nil { |
... | ... |
@@ -94,7 +94,7 @@ func TestCommitPausedContainer(t *testing.T) { |
94 | 94 |
if err != nil { |
95 | 95 |
t.Fatalf("failed to commit container to image: %s, %v", out, err) |
96 | 96 |
} |
97 |
- cleanedImageID := stripTrailingCharacters(out) |
|
97 |
+ cleanedImageID := strings.TrimSpace(out) |
|
98 | 98 |
defer deleteImages(cleanedImageID) |
99 | 99 |
|
100 | 100 |
cmd = exec.Command(dockerBinary, "inspect", "-f", "{{.State.Paused}}", cleanedContainerID) |
... | ... |
@@ -30,11 +30,11 @@ func TestCpGarbagePath(t *testing.T) { |
30 | 30 |
t.Fatal("failed to create a container", out, err) |
31 | 31 |
} |
32 | 32 |
|
33 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
33 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
34 | 34 |
defer deleteContainer(cleanedContainerID) |
35 | 35 |
|
36 | 36 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
37 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
37 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
38 | 38 |
t.Fatal("failed to set up container", out, err) |
39 | 39 |
} |
40 | 40 |
|
... | ... |
@@ -92,11 +92,11 @@ func TestCpRelativePath(t *testing.T) { |
92 | 92 |
t.Fatal("failed to create a container", out, err) |
93 | 93 |
} |
94 | 94 |
|
95 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
95 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
96 | 96 |
defer deleteContainer(cleanedContainerID) |
97 | 97 |
|
98 | 98 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
99 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
99 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
100 | 100 |
t.Fatal("failed to set up container", out, err) |
101 | 101 |
} |
102 | 102 |
|
... | ... |
@@ -162,11 +162,11 @@ func TestCpAbsolutePath(t *testing.T) { |
162 | 162 |
t.Fatal("failed to create a container", out, err) |
163 | 163 |
} |
164 | 164 |
|
165 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
165 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
166 | 166 |
defer deleteContainer(cleanedContainerID) |
167 | 167 |
|
168 | 168 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
169 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
169 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
170 | 170 |
t.Fatal("failed to set up container", out, err) |
171 | 171 |
} |
172 | 172 |
|
... | ... |
@@ -226,11 +226,11 @@ func TestCpAbsoluteSymlink(t *testing.T) { |
226 | 226 |
t.Fatal("failed to create a container", out, err) |
227 | 227 |
} |
228 | 228 |
|
229 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
229 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
230 | 230 |
defer deleteContainer(cleanedContainerID) |
231 | 231 |
|
232 | 232 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
233 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
233 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
234 | 234 |
t.Fatal("failed to set up container", out, err) |
235 | 235 |
} |
236 | 236 |
|
... | ... |
@@ -290,11 +290,11 @@ func TestCpSymlinkComponent(t *testing.T) { |
290 | 290 |
t.Fatal("failed to create a container", out, err) |
291 | 291 |
} |
292 | 292 |
|
293 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
293 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
294 | 294 |
defer deleteContainer(cleanedContainerID) |
295 | 295 |
|
296 | 296 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
297 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
297 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
298 | 298 |
t.Fatal("failed to set up container", out, err) |
299 | 299 |
} |
300 | 300 |
|
... | ... |
@@ -355,11 +355,11 @@ func TestCpUnprivilegedUser(t *testing.T) { |
355 | 355 |
t.Fatal("failed to create a container", out, err) |
356 | 356 |
} |
357 | 357 |
|
358 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
358 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
359 | 359 |
defer deleteContainer(cleanedContainerID) |
360 | 360 |
|
361 | 361 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
362 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
362 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
363 | 363 |
t.Fatal("failed to set up container", out, err) |
364 | 364 |
} |
365 | 365 |
|
... | ... |
@@ -398,11 +398,11 @@ func TestCpSpecialFiles(t *testing.T) { |
398 | 398 |
t.Fatal("failed to create a container", out, err) |
399 | 399 |
} |
400 | 400 |
|
401 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
401 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
402 | 402 |
defer deleteContainer(cleanedContainerID) |
403 | 403 |
|
404 | 404 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
405 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
405 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
406 | 406 |
t.Fatal("failed to set up container", out, err) |
407 | 407 |
} |
408 | 408 |
|
... | ... |
@@ -471,11 +471,11 @@ func TestCpVolumePath(t *testing.T) { |
471 | 471 |
t.Fatal("failed to create a container", out, err) |
472 | 472 |
} |
473 | 473 |
|
474 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
474 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
475 | 475 |
defer deleteContainer(cleanedContainerID) |
476 | 476 |
|
477 | 477 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
478 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
478 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
479 | 479 |
t.Fatal("failed to set up container", out, err) |
480 | 480 |
} |
481 | 481 |
|
... | ... |
@@ -562,11 +562,11 @@ func TestCpToDot(t *testing.T) { |
562 | 562 |
t.Fatal("failed to create a container", out, err) |
563 | 563 |
} |
564 | 564 |
|
565 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
565 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
566 | 566 |
defer deleteContainer(cleanedContainerID) |
567 | 567 |
|
568 | 568 |
out, _, err = dockerCmd(t, "wait", cleanedContainerID) |
569 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
569 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
570 | 570 |
t.Fatal("failed to set up container", out, err) |
571 | 571 |
} |
572 | 572 |
|
... | ... |
@@ -600,11 +600,11 @@ func TestCpToStdout(t *testing.T) { |
600 | 600 |
t.Fatalf("failed to create a container:%s\n%s", out, err) |
601 | 601 |
} |
602 | 602 |
|
603 |
- cID := stripTrailingCharacters(out) |
|
603 |
+ cID := strings.TrimSpace(out) |
|
604 | 604 |
defer deleteContainer(cID) |
605 | 605 |
|
606 | 606 |
out, _, err = dockerCmd(t, "wait", cID) |
607 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
607 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
608 | 608 |
t.Fatalf("failed to set up container:%s\n%s", out, err) |
609 | 609 |
} |
610 | 610 |
|
... | ... |
@@ -5,6 +5,7 @@ import ( |
5 | 5 |
"os" |
6 | 6 |
"os/exec" |
7 | 7 |
"reflect" |
8 |
+ "strings" |
|
8 | 9 |
"testing" |
9 | 10 |
"time" |
10 | 11 |
|
... | ... |
@@ -21,7 +22,7 @@ func TestCreateArgs(t *testing.T) { |
21 | 21 |
t.Fatal(out, err) |
22 | 22 |
} |
23 | 23 |
|
24 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
24 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
25 | 25 |
|
26 | 26 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
27 | 27 |
out, _, err = runCommandWithOutput(inspectCmd) |
... | ... |
@@ -73,7 +74,7 @@ func TestCreateHostConfig(t *testing.T) { |
73 | 73 |
t.Fatal(out, err) |
74 | 74 |
} |
75 | 75 |
|
76 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
76 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
77 | 77 |
|
78 | 78 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
79 | 79 |
out, _, err = runCommandWithOutput(inspectCmd) |
... | ... |
@@ -114,7 +115,7 @@ func TestCreateWithPortRange(t *testing.T) { |
114 | 114 |
t.Fatal(out, err) |
115 | 115 |
} |
116 | 116 |
|
117 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
117 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
118 | 118 |
|
119 | 119 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
120 | 120 |
out, _, err = runCommandWithOutput(inspectCmd) |
... | ... |
@@ -163,7 +164,7 @@ func TestCreateWithiLargePortRange(t *testing.T) { |
163 | 163 |
t.Fatal(out, err) |
164 | 164 |
} |
165 | 165 |
|
166 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
166 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
167 | 167 |
|
168 | 168 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
169 | 169 |
out, _, err = runCommandWithOutput(inspectCmd) |
... | ... |
@@ -213,7 +214,7 @@ func TestCreateEchoStdout(t *testing.T) { |
213 | 213 |
t.Fatal(out, err) |
214 | 214 |
} |
215 | 215 |
|
216 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
216 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
217 | 217 |
|
218 | 218 |
runCmd = exec.Command(dockerBinary, "start", "-ai", cleanedContainerID) |
219 | 219 |
out, _, _, err = runCommandWithStdoutStderr(runCmd) |
... | ... |
@@ -15,7 +15,7 @@ func TestDiffFilenameShownInOutput(t *testing.T) { |
15 | 15 |
t.Fatalf("failed to start the container: %s, %v", out, err) |
16 | 16 |
} |
17 | 17 |
|
18 |
- cleanCID := stripTrailingCharacters(out) |
|
18 |
+ cleanCID := strings.TrimSpace(out) |
|
19 | 19 |
|
20 | 20 |
diffCmd := exec.Command(dockerBinary, "diff", cleanCID) |
21 | 21 |
out, _, err = runCommandWithOutput(diffCmd) |
... | ... |
@@ -52,7 +52,7 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) { |
52 | 52 |
t.Fatal(out, err) |
53 | 53 |
} |
54 | 54 |
|
55 |
- cleanCID := stripTrailingCharacters(out) |
|
55 |
+ cleanCID := strings.TrimSpace(out) |
|
56 | 56 |
|
57 | 57 |
diffCmd := exec.Command(dockerBinary, "diff", cleanCID) |
58 | 58 |
out, _, err = runCommandWithOutput(diffCmd) |
... | ... |
@@ -79,7 +79,7 @@ func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) { |
79 | 79 |
t.Fatal(out, err) |
80 | 80 |
} |
81 | 81 |
|
82 |
- cleanCID := stripTrailingCharacters(out) |
|
82 |
+ cleanCID := strings.TrimSpace(out) |
|
83 | 83 |
|
84 | 84 |
diffCmd := exec.Command(dockerBinary, "diff", cleanCID) |
85 | 85 |
out, _, err = runCommandWithOutput(diffCmd) |
... | ... |
@@ -182,7 +182,7 @@ func TestEventsImageImport(t *testing.T) { |
182 | 182 |
if err != nil { |
183 | 183 |
t.Fatal("failed to create a container", out, err) |
184 | 184 |
} |
185 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
185 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
186 | 186 |
|
187 | 187 |
out, _, err = runCommandPipelineWithOutput( |
188 | 188 |
exec.Command(dockerBinary, "export", cleanedContainerID), |
... | ... |
@@ -258,13 +258,13 @@ func TestEventsFilterImageName(t *testing.T) { |
258 | 258 |
if err != nil { |
259 | 259 |
t.Fatal(out, err) |
260 | 260 |
} |
261 |
- container1 := stripTrailingCharacters(out) |
|
261 |
+ container1 := strings.TrimSpace(out) |
|
262 | 262 |
|
263 | 263 |
out, _, err = runCommandWithOutput(exec.Command(dockerBinary, "run", "--name", "container_2", "-d", "busybox", "true")) |
264 | 264 |
if err != nil { |
265 | 265 |
t.Fatal(out, err) |
266 | 266 |
} |
267 |
- container2 := stripTrailingCharacters(out) |
|
267 |
+ container2 := strings.TrimSpace(out) |
|
268 | 268 |
|
269 | 269 |
for _, s := range []string{"busybox", "busybox:latest"} { |
270 | 270 |
eventsCmd := exec.Command(dockerBinary, "events", fmt.Sprintf("--since=%d", since), fmt.Sprintf("--until=%d", daemonTime(t).Unix()), "--filter", fmt.Sprintf("image=%s", s)) |
... | ... |
@@ -302,13 +302,13 @@ func TestEventsFilterContainerID(t *testing.T) { |
302 | 302 |
if err != nil { |
303 | 303 |
t.Fatal(out, err) |
304 | 304 |
} |
305 |
- container1 := stripTrailingCharacters(out) |
|
305 |
+ container1 := strings.TrimSpace(out) |
|
306 | 306 |
|
307 | 307 |
out, _, err = runCommandWithOutput(exec.Command(dockerBinary, "run", "-d", "busybox", "true")) |
308 | 308 |
if err != nil { |
309 | 309 |
t.Fatal(out, err) |
310 | 310 |
} |
311 |
- container2 := stripTrailingCharacters(out) |
|
311 |
+ container2 := strings.TrimSpace(out) |
|
312 | 312 |
|
313 | 313 |
for _, s := range []string{container1, container2, container1[:12], container2[:12]} { |
314 | 314 |
eventsCmd := exec.Command(dockerBinary, "events", fmt.Sprintf("--since=%d", since), fmt.Sprintf("--until=%d", daemonTime(t).Unix()), "--filter", fmt.Sprintf("container=%s", s)) |
... | ... |
@@ -141,7 +141,7 @@ func TestExecAfterContainerRestart(t *testing.T) { |
141 | 141 |
t.Fatal(out, err) |
142 | 142 |
} |
143 | 143 |
|
144 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
144 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
145 | 145 |
|
146 | 146 |
runCmd = exec.Command(dockerBinary, "restart", cleanedContainerID) |
147 | 147 |
if out, _, err = runCommandWithOutput(runCmd); err != nil { |
... | ... |
@@ -253,7 +253,7 @@ func TestExecPausedContainer(t *testing.T) { |
253 | 253 |
t.Fatal(out, err) |
254 | 254 |
} |
255 | 255 |
|
256 |
- ContainerID := stripTrailingCharacters(out) |
|
256 |
+ ContainerID := strings.TrimSpace(out) |
|
257 | 257 |
|
258 | 258 |
pausedCmd := exec.Command(dockerBinary, "pause", "testing") |
259 | 259 |
out, _, _, err = runCommandWithStdoutStderr(pausedCmd) |
... | ... |
@@ -501,12 +501,12 @@ func TestLinksPingLinkedContainersOnRename(t *testing.T) { |
501 | 501 |
|
502 | 502 |
var out string |
503 | 503 |
out, _, _ = dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10") |
504 |
- idA := stripTrailingCharacters(out) |
|
504 |
+ idA := strings.TrimSpace(out) |
|
505 | 505 |
if idA == "" { |
506 | 506 |
t.Fatal(out, "id should not be nil") |
507 | 507 |
} |
508 | 508 |
out, _, _ = dockerCmd(t, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "sleep", "10") |
509 |
- idB := stripTrailingCharacters(out) |
|
509 |
+ idB := strings.TrimSpace(out) |
|
510 | 510 |
if idB == "" { |
511 | 511 |
t.Fatal(out, "id should not be nil") |
512 | 512 |
} |
... | ... |
@@ -15,7 +15,7 @@ func TestExportContainerAndImportImage(t *testing.T) { |
15 | 15 |
t.Fatal("failed to create a container", out, err) |
16 | 16 |
} |
17 | 17 |
|
18 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
18 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
19 | 19 |
|
20 | 20 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
21 | 21 |
out, _, err = runCommandWithOutput(inspectCmd) |
... | ... |
@@ -35,7 +35,7 @@ func TestExportContainerAndImportImage(t *testing.T) { |
35 | 35 |
t.Fatalf("failed to import image: %s, %v", out, err) |
36 | 36 |
} |
37 | 37 |
|
38 |
- cleanedImageID := stripTrailingCharacters(out) |
|
38 |
+ cleanedImageID := strings.TrimSpace(out) |
|
39 | 39 |
|
40 | 40 |
inspectCmd = exec.Command(dockerBinary, "inspect", cleanedImageID) |
41 | 41 |
if out, _, err = runCommandWithOutput(inspectCmd); err != nil { |
... | ... |
@@ -56,7 +56,7 @@ func TestExportContainerWithOutputAndImportImage(t *testing.T) { |
56 | 56 |
t.Fatal("failed to create a container", out, err) |
57 | 57 |
} |
58 | 58 |
|
59 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
59 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
60 | 60 |
|
61 | 61 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
62 | 62 |
out, _, err = runCommandWithOutput(inspectCmd) |
... | ... |
@@ -81,7 +81,7 @@ func TestExportContainerWithOutputAndImportImage(t *testing.T) { |
81 | 81 |
t.Fatalf("failed to import image: %s, %v", out, err) |
82 | 82 |
} |
83 | 83 |
|
84 |
- cleanedImageID := stripTrailingCharacters(out) |
|
84 |
+ cleanedImageID := strings.TrimSpace(out) |
|
85 | 85 |
|
86 | 86 |
inspectCmd = exec.Command(dockerBinary, "inspect", cleanedImageID) |
87 | 87 |
if out, _, err = runCommandWithOutput(inspectCmd); err != nil { |
... | ... |
@@ -12,7 +12,7 @@ func TestImportDisplay(t *testing.T) { |
12 | 12 |
if err != nil { |
13 | 13 |
t.Fatal("failed to create a container", out, err) |
14 | 14 |
} |
15 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
15 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
16 | 16 |
defer deleteContainer(cleanedContainerID) |
17 | 17 |
|
18 | 18 |
out, _, err = runCommandPipelineWithOutput( |
... | ... |
@@ -13,7 +13,7 @@ func TestKillContainer(t *testing.T) { |
13 | 13 |
t.Fatal(out, err) |
14 | 14 |
} |
15 | 15 |
|
16 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
16 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
17 | 17 |
|
18 | 18 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
19 | 19 |
if out, _, err = runCommandWithOutput(inspectCmd); err != nil { |
... | ... |
@@ -47,7 +47,7 @@ func TestKillDifferentUserContainer(t *testing.T) { |
47 | 47 |
t.Fatal(out, err) |
48 | 48 |
} |
49 | 49 |
|
50 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
50 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
51 | 51 |
|
52 | 52 |
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID) |
53 | 53 |
if out, _, err = runCommandWithOutput(inspectCmd); err != nil { |
... | ... |
@@ -111,9 +111,9 @@ func TestLinksPingLinkedContainersAfterRename(t *testing.T) { |
111 | 111 |
defer deleteAllContainers() |
112 | 112 |
|
113 | 113 |
out, _, _ := dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10") |
114 |
- idA := stripTrailingCharacters(out) |
|
114 |
+ idA := strings.TrimSpace(out) |
|
115 | 115 |
out, _, _ = dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10") |
116 |
- idB := stripTrailingCharacters(out) |
|
116 |
+ idB := strings.TrimSpace(out) |
|
117 | 117 |
dockerCmd(t, "rename", "container1", "container_new") |
118 | 118 |
dockerCmd(t, "run", "--rm", "--link", "container_new:alias1", "--link", "container2:alias2", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1") |
119 | 119 |
dockerCmd(t, "kill", idA) |
... | ... |
@@ -20,7 +20,7 @@ func TestLogsContainerSmallerThanPage(t *testing.T) { |
20 | 20 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
21 | 21 |
} |
22 | 22 |
|
23 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
23 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
24 | 24 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
25 | 25 |
|
26 | 26 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
... | ... |
@@ -47,7 +47,7 @@ func TestLogsContainerBiggerThanPage(t *testing.T) { |
47 | 47 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
48 | 48 |
} |
49 | 49 |
|
50 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
50 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
51 | 51 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
52 | 52 |
|
53 | 53 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
... | ... |
@@ -74,7 +74,7 @@ func TestLogsContainerMuchBiggerThanPage(t *testing.T) { |
74 | 74 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
75 | 75 |
} |
76 | 76 |
|
77 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
77 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
78 | 78 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
79 | 79 |
|
80 | 80 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
... | ... |
@@ -101,7 +101,7 @@ func TestLogsTimestamps(t *testing.T) { |
101 | 101 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
102 | 102 |
} |
103 | 103 |
|
104 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
104 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
105 | 105 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
106 | 106 |
|
107 | 107 |
logsCmd := exec.Command(dockerBinary, "logs", "-t", cleanedContainerID) |
... | ... |
@@ -144,7 +144,7 @@ func TestLogsSeparateStderr(t *testing.T) { |
144 | 144 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
145 | 145 |
} |
146 | 146 |
|
147 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
147 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
148 | 148 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
149 | 149 |
|
150 | 150 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
... | ... |
@@ -176,7 +176,7 @@ func TestLogsStderrInStdout(t *testing.T) { |
176 | 176 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
177 | 177 |
} |
178 | 178 |
|
179 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
179 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
180 | 180 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
181 | 181 |
|
182 | 182 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
... | ... |
@@ -208,7 +208,7 @@ func TestLogsTail(t *testing.T) { |
208 | 208 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
209 | 209 |
} |
210 | 210 |
|
211 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
211 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
212 | 212 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
213 | 213 |
|
214 | 214 |
logsCmd := exec.Command(dockerBinary, "logs", "--tail", "5", cleanedContainerID) |
... | ... |
@@ -259,7 +259,7 @@ func TestLogsFollowStopped(t *testing.T) { |
259 | 259 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
260 | 260 |
} |
261 | 261 |
|
262 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
262 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
263 | 263 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
264 | 264 |
|
265 | 265 |
logsCmd := exec.Command(dockerBinary, "logs", "-f", cleanedContainerID) |
... | ... |
@@ -294,7 +294,7 @@ func TestLogsFollowSlowStdoutConsumer(t *testing.T) { |
294 | 294 |
t.Fatalf("run failed with errors: %s, %v", out, err) |
295 | 295 |
} |
296 | 296 |
|
297 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
297 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
298 | 298 |
defer deleteContainer(cleanedContainerID) |
299 | 299 |
|
300 | 300 |
stopSlowRead := make(chan bool) |
... | ... |
@@ -33,7 +33,7 @@ func TestNetworkNat(t *testing.T) { |
33 | 33 |
t.Fatal(out, err) |
34 | 34 |
} |
35 | 35 |
|
36 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
36 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
37 | 37 |
|
38 | 38 |
runCmd = exec.Command(dockerBinary, "run", "busybox", "sh", "-c", fmt.Sprintf("echo hello world | nc -w 30 %s 8080", ifaceIP)) |
39 | 39 |
out, _, err = runCommandWithOutput(runCmd) |
... | ... |
@@ -16,7 +16,7 @@ func TestPortList(t *testing.T) { |
16 | 16 |
if err != nil { |
17 | 17 |
t.Fatal(out, err) |
18 | 18 |
} |
19 |
- firstID := stripTrailingCharacters(out) |
|
19 |
+ firstID := strings.TrimSpace(out) |
|
20 | 20 |
|
21 | 21 |
runCmd = exec.Command(dockerBinary, "port", firstID, "80") |
22 | 22 |
out, _, err = runCommandWithOutput(runCmd) |
... | ... |
@@ -52,7 +52,7 @@ func TestPortList(t *testing.T) { |
52 | 52 |
if err != nil { |
53 | 53 |
t.Fatal(out, err) |
54 | 54 |
} |
55 |
- ID := stripTrailingCharacters(out) |
|
55 |
+ ID := strings.TrimSpace(out) |
|
56 | 56 |
|
57 | 57 |
runCmd = exec.Command(dockerBinary, "port", ID, "80") |
58 | 58 |
out, _, err = runCommandWithOutput(runCmd) |
... | ... |
@@ -93,7 +93,7 @@ func TestPortList(t *testing.T) { |
93 | 93 |
if err != nil { |
94 | 94 |
t.Fatal(out, err) |
95 | 95 |
} |
96 |
- ID = stripTrailingCharacters(out) |
|
96 |
+ ID = strings.TrimSpace(out) |
|
97 | 97 |
|
98 | 98 |
runCmd = exec.Command(dockerBinary, "port", ID, "80") |
99 | 99 |
out, _, err = runCommandWithOutput(runCmd) |
... | ... |
@@ -18,14 +18,14 @@ func TestPsListContainers(t *testing.T) { |
18 | 18 |
if err != nil { |
19 | 19 |
t.Fatal(out, err) |
20 | 20 |
} |
21 |
- firstID := stripTrailingCharacters(out) |
|
21 |
+ firstID := strings.TrimSpace(out) |
|
22 | 22 |
|
23 | 23 |
runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "top") |
24 | 24 |
out, _, err = runCommandWithOutput(runCmd) |
25 | 25 |
if err != nil { |
26 | 26 |
t.Fatal(out, err) |
27 | 27 |
} |
28 |
- secondID := stripTrailingCharacters(out) |
|
28 |
+ secondID := strings.TrimSpace(out) |
|
29 | 29 |
|
30 | 30 |
// not long running |
31 | 31 |
runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "true") |
... | ... |
@@ -33,14 +33,14 @@ func TestPsListContainers(t *testing.T) { |
33 | 33 |
if err != nil { |
34 | 34 |
t.Fatal(out, err) |
35 | 35 |
} |
36 |
- thirdID := stripTrailingCharacters(out) |
|
36 |
+ thirdID := strings.TrimSpace(out) |
|
37 | 37 |
|
38 | 38 |
runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "top") |
39 | 39 |
out, _, err = runCommandWithOutput(runCmd) |
40 | 40 |
if err != nil { |
41 | 41 |
t.Fatal(out, err) |
42 | 42 |
} |
43 |
- fourthID := stripTrailingCharacters(out) |
|
43 |
+ fourthID := strings.TrimSpace(out) |
|
44 | 44 |
|
45 | 45 |
// make sure third one is not running |
46 | 46 |
runCmd = exec.Command(dockerBinary, "wait", thirdID) |
... | ... |
@@ -312,7 +312,7 @@ func TestPsListContainersFilterStatus(t *testing.T) { |
312 | 312 |
if err != nil { |
313 | 313 |
t.Fatal(out, err) |
314 | 314 |
} |
315 |
- firstID := stripTrailingCharacters(out) |
|
315 |
+ firstID := strings.TrimSpace(out) |
|
316 | 316 |
|
317 | 317 |
// make sure the exited cintainer is not running |
318 | 318 |
runCmd = exec.Command(dockerBinary, "wait", firstID) |
... | ... |
@@ -326,7 +326,7 @@ func TestPsListContainersFilterStatus(t *testing.T) { |
326 | 326 |
if err != nil { |
327 | 327 |
t.Fatal(out, err) |
328 | 328 |
} |
329 |
- secondID := stripTrailingCharacters(out) |
|
329 |
+ secondID := strings.TrimSpace(out) |
|
330 | 330 |
|
331 | 331 |
// filter containers by exited |
332 | 332 |
runCmd = exec.Command(dockerBinary, "ps", "-q", "--filter=status=exited") |
... | ... |
@@ -361,7 +361,7 @@ func TestPsListContainersFilterID(t *testing.T) { |
361 | 361 |
if err != nil { |
362 | 362 |
t.Fatal(out, err) |
363 | 363 |
} |
364 |
- firstID := stripTrailingCharacters(out) |
|
364 |
+ firstID := strings.TrimSpace(out) |
|
365 | 365 |
|
366 | 366 |
// start another container |
367 | 367 |
runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "sleep 360") |
... | ... |
@@ -391,7 +391,7 @@ func TestPsListContainersFilterName(t *testing.T) { |
391 | 391 |
if err != nil { |
392 | 392 |
t.Fatal(out, err) |
393 | 393 |
} |
394 |
- firstID := stripTrailingCharacters(out) |
|
394 |
+ firstID := strings.TrimSpace(out) |
|
395 | 395 |
|
396 | 396 |
// start another container |
397 | 397 |
runCmd = exec.Command(dockerBinary, "run", "-d", "--name=b_name_to_match", "busybox", "sh", "-c", "sleep 360") |
... | ... |
@@ -419,21 +419,21 @@ func TestPsListContainersFilterLabel(t *testing.T) { |
419 | 419 |
if err != nil { |
420 | 420 |
t.Fatal(out, err) |
421 | 421 |
} |
422 |
- firstID := stripTrailingCharacters(out) |
|
422 |
+ firstID := strings.TrimSpace(out) |
|
423 | 423 |
|
424 | 424 |
// start another container |
425 | 425 |
runCmd = exec.Command(dockerBinary, "run", "-d", "-l", "match=me too", "busybox") |
426 | 426 |
if out, _, err = runCommandWithOutput(runCmd); err != nil { |
427 | 427 |
t.Fatal(out, err) |
428 | 428 |
} |
429 |
- secondID := stripTrailingCharacters(out) |
|
429 |
+ secondID := strings.TrimSpace(out) |
|
430 | 430 |
|
431 | 431 |
// start third container |
432 | 432 |
runCmd = exec.Command(dockerBinary, "run", "-d", "-l", "nomatch=me", "busybox") |
433 | 433 |
if out, _, err = runCommandWithOutput(runCmd); err != nil { |
434 | 434 |
t.Fatal(out, err) |
435 | 435 |
} |
436 |
- thirdID := stripTrailingCharacters(out) |
|
436 |
+ thirdID := strings.TrimSpace(out) |
|
437 | 437 |
|
438 | 438 |
// filter containers by exact match |
439 | 439 |
runCmd = exec.Command(dockerBinary, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me") |
... | ... |
@@ -15,7 +15,7 @@ func TestRenameStoppedContainer(t *testing.T) { |
15 | 15 |
t.Fatalf(out, err) |
16 | 16 |
} |
17 | 17 |
|
18 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
18 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
19 | 19 |
|
20 | 20 |
runCmd = exec.Command(dockerBinary, "wait", cleanedContainerID) |
21 | 21 |
out, _, err = runCommandWithOutput(runCmd) |
... | ... |
@@ -51,7 +51,7 @@ func TestRenameRunningContainer(t *testing.T) { |
51 | 51 |
t.Fatalf(out, err) |
52 | 52 |
} |
53 | 53 |
|
54 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
54 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
55 | 55 |
runCmd = exec.Command(dockerBinary, "rename", "first_name", "new_name") |
56 | 56 |
out, _, err = runCommandWithOutput(runCmd) |
57 | 57 |
if err != nil { |
... | ... |
@@ -16,7 +16,7 @@ func TestRestartStoppedContainer(t *testing.T) { |
16 | 16 |
t.Fatal(out, err) |
17 | 17 |
} |
18 | 18 |
|
19 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
19 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
20 | 20 |
|
21 | 21 |
runCmd = exec.Command(dockerBinary, "wait", cleanedContainerID) |
22 | 22 |
if out, _, err = runCommandWithOutput(runCmd); err != nil { |
... | ... |
@@ -60,7 +60,7 @@ func TestRestartRunningContainer(t *testing.T) { |
60 | 60 |
t.Fatal(out, err) |
61 | 61 |
} |
62 | 62 |
|
63 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
63 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
64 | 64 |
|
65 | 65 |
time.Sleep(1 * time.Second) |
66 | 66 |
|
... | ... |
@@ -104,7 +104,7 @@ func TestRestartWithVolumes(t *testing.T) { |
104 | 104 |
t.Fatal(out, err) |
105 | 105 |
} |
106 | 106 |
|
107 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
107 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
108 | 108 |
|
109 | 109 |
runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ len .Volumes }}", cleanedContainerID) |
110 | 110 |
out, _, err = runCommandWithOutput(runCmd) |
... | ... |
@@ -16,7 +16,7 @@ func TestRmiWithContainerFails(t *testing.T) { |
16 | 16 |
t.Fatalf("failed to create a container: %s, %v", out, err) |
17 | 17 |
} |
18 | 18 |
|
19 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
19 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
20 | 20 |
|
21 | 21 |
// try to delete the image |
22 | 22 |
runCmd = exec.Command(dockerBinary, "rmi", "busybox") |
... | ... |
@@ -199,7 +199,7 @@ func TestRunStdinPipe(t *testing.T) { |
199 | 199 |
t.Fatalf("failed to run container: %v, output: %q", err, out) |
200 | 200 |
} |
201 | 201 |
|
202 |
- out = stripTrailingCharacters(out) |
|
202 |
+ out = strings.TrimSpace(out) |
|
203 | 203 |
|
204 | 204 |
inspectCmd := exec.Command(dockerBinary, "inspect", out) |
205 | 205 |
if out, _, err := runCommandWithOutput(inspectCmd); err != nil { |
... | ... |
@@ -217,7 +217,7 @@ func TestRunStdinPipe(t *testing.T) { |
217 | 217 |
t.Fatalf("error thrown while trying to get container logs: %s, %v", logsOut, err) |
218 | 218 |
} |
219 | 219 |
|
220 |
- containerLogs := stripTrailingCharacters(logsOut) |
|
220 |
+ containerLogs := strings.TrimSpace(logsOut) |
|
221 | 221 |
|
222 | 222 |
if containerLogs != "blahblah" { |
223 | 223 |
t.Errorf("logs didn't print the container's logs %s", containerLogs) |
... | ... |
@@ -241,7 +241,7 @@ func TestRunDetachedContainerIDPrinting(t *testing.T) { |
241 | 241 |
t.Fatalf("failed to run container: %v, output: %q", err, out) |
242 | 242 |
} |
243 | 243 |
|
244 |
- out = stripTrailingCharacters(out) |
|
244 |
+ out = strings.TrimSpace(out) |
|
245 | 245 |
|
246 | 246 |
inspectCmd := exec.Command(dockerBinary, "inspect", out) |
247 | 247 |
if inspectOut, _, err := runCommandWithOutput(inspectCmd); err != nil { |
... | ... |
@@ -259,7 +259,7 @@ func TestRunDetachedContainerIDPrinting(t *testing.T) { |
259 | 259 |
t.Fatalf("rm failed to remove container: %s, %v", rmOut, err) |
260 | 260 |
} |
261 | 261 |
|
262 |
- rmOut = stripTrailingCharacters(rmOut) |
|
262 |
+ rmOut = strings.TrimSpace(rmOut) |
|
263 | 263 |
if rmOut != out { |
264 | 264 |
t.Errorf("rm didn't print the container ID %s %s", out, rmOut) |
265 | 265 |
} |
... | ... |
@@ -277,7 +277,7 @@ func TestRunWorkingDirectory(t *testing.T) { |
277 | 277 |
t.Fatalf("failed to run container: %v, output: %q", err, out) |
278 | 278 |
} |
279 | 279 |
|
280 |
- out = stripTrailingCharacters(out) |
|
280 |
+ out = strings.TrimSpace(out) |
|
281 | 281 |
|
282 | 282 |
if out != "/root" { |
283 | 283 |
t.Errorf("-w failed to set working directory") |
... | ... |
@@ -289,7 +289,7 @@ func TestRunWorkingDirectory(t *testing.T) { |
289 | 289 |
t.Fatal(out, err) |
290 | 290 |
} |
291 | 291 |
|
292 |
- out = stripTrailingCharacters(out) |
|
292 |
+ out = strings.TrimSpace(out) |
|
293 | 293 |
|
294 | 294 |
if out != "/root" { |
295 | 295 |
t.Errorf("--workdir failed to set working directory") |
... | ... |
@@ -2215,7 +2215,7 @@ func TestRunWriteHostsFileAndNotCommit(t *testing.T) { |
2215 | 2215 |
func eqToBaseDiff(out string, t *testing.T) bool { |
2216 | 2216 |
cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello") |
2217 | 2217 |
out1, _, err := runCommandWithOutput(cmd) |
2218 |
- cID := stripTrailingCharacters(out1) |
|
2218 |
+ cID := strings.TrimSpace(out1) |
|
2219 | 2219 |
cmd = exec.Command(dockerBinary, "diff", cID) |
2220 | 2220 |
baseDiff, _, err := runCommandWithOutput(cmd) |
2221 | 2221 |
if err != nil { |
... | ... |
@@ -20,7 +20,7 @@ func TestSaveXzAndLoadRepoStdout(t *testing.T) { |
20 | 20 |
t.Fatalf("failed to create a container: %v %v", out, err) |
21 | 21 |
} |
22 | 22 |
|
23 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
23 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
24 | 24 |
|
25 | 25 |
repoName := "foobar-save-load-test-xz-gz" |
26 | 26 |
|
... | ... |
@@ -77,7 +77,7 @@ func TestSaveXzGzAndLoadRepoStdout(t *testing.T) { |
77 | 77 |
t.Fatalf("failed to create a container: %v %v", out, err) |
78 | 78 |
} |
79 | 79 |
|
80 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
80 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
81 | 81 |
|
82 | 82 |
repoName := "foobar-save-load-test-xz-gz" |
83 | 83 |
|
... | ... |
@@ -142,7 +142,7 @@ func TestSaveSingleTag(t *testing.T) { |
142 | 142 |
if err != nil { |
143 | 143 |
t.Fatalf("failed to get repo ID: %s, %v", out, err) |
144 | 144 |
} |
145 |
- cleanedImageID := stripTrailingCharacters(out) |
|
145 |
+ cleanedImageID := strings.TrimSpace(out) |
|
146 | 146 |
|
147 | 147 |
out, _, err = runCommandPipelineWithOutput( |
148 | 148 |
exec.Command(dockerBinary, "save", fmt.Sprintf("%v:latest", repoName)), |
... | ... |
@@ -170,7 +170,7 @@ func TestSaveImageId(t *testing.T) { |
170 | 170 |
t.Fatalf("failed to get repo ID: %s, %v", out, err) |
171 | 171 |
} |
172 | 172 |
|
173 |
- cleanedLongImageID := stripTrailingCharacters(out) |
|
173 |
+ cleanedLongImageID := strings.TrimSpace(out) |
|
174 | 174 |
|
175 | 175 |
idShortCmd := exec.Command(dockerBinary, "images", "-q", repoName) |
176 | 176 |
out, _, err = runCommandWithOutput(idShortCmd) |
... | ... |
@@ -178,7 +178,7 @@ func TestSaveImageId(t *testing.T) { |
178 | 178 |
t.Fatalf("failed to get repo short ID: %s, %v", out, err) |
179 | 179 |
} |
180 | 180 |
|
181 |
- cleanedShortImageID := stripTrailingCharacters(out) |
|
181 |
+ cleanedShortImageID := strings.TrimSpace(out) |
|
182 | 182 |
|
183 | 183 |
saveCmd := exec.Command(dockerBinary, "save", cleanedShortImageID) |
184 | 184 |
tarCmd := exec.Command("tar", "t") |
... | ... |
@@ -218,7 +218,7 @@ func TestSaveAndLoadRepoFlags(t *testing.T) { |
218 | 218 |
t.Fatalf("failed to create a container: %s, %v", out, err) |
219 | 219 |
} |
220 | 220 |
|
221 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
221 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
222 | 222 |
defer deleteContainer(cleanedContainerID) |
223 | 223 |
|
224 | 224 |
repoName := "foobar-save-load-test" |
... | ... |
@@ -302,14 +302,14 @@ func TestSaveRepoWithMultipleImages(t *testing.T) { |
302 | 302 |
if out, _, err = runCommandWithOutput(runCmd); err != nil { |
303 | 303 |
t.Fatalf("failed to create a container: %v %v", out, err) |
304 | 304 |
} |
305 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
305 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
306 | 306 |
defer deleteContainer(cleanedContainerID) |
307 | 307 |
|
308 | 308 |
commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, tag) |
309 | 309 |
if out, _, err = runCommandWithOutput(commitCmd); err != nil { |
310 | 310 |
t.Fatalf("failed to commit container: %v %v", out, err) |
311 | 311 |
} |
312 |
- imageID := stripTrailingCharacters(out) |
|
312 |
+ imageID := strings.TrimSpace(out) |
|
313 | 313 |
return imageID |
314 | 314 |
} |
315 | 315 |
|
... | ... |
@@ -333,7 +333,7 @@ func TestSaveRepoWithMultipleImages(t *testing.T) { |
333 | 333 |
if err != nil { |
334 | 334 |
t.Fatalf("failed to save multiple images: %s, %v", out, err) |
335 | 335 |
} |
336 |
- actual := strings.Split(stripTrailingCharacters(out), "\n") |
|
336 |
+ actual := strings.Split(strings.TrimSpace(out), "\n") |
|
337 | 337 |
|
338 | 338 |
// make the list of expected layers |
339 | 339 |
out, _, err = runCommandWithOutput(exec.Command(dockerBinary, "history", "-q", "--no-trunc", "busybox:latest")) |
... | ... |
@@ -341,7 +341,7 @@ func TestSaveRepoWithMultipleImages(t *testing.T) { |
341 | 341 |
t.Fatalf("failed to get history: %s, %v", out, err) |
342 | 342 |
} |
343 | 343 |
|
344 |
- expected := append(strings.Split(stripTrailingCharacters(out), "\n"), idFoo, idBar) |
|
344 |
+ expected := append(strings.Split(strings.TrimSpace(out), "\n"), idFoo, idBar) |
|
345 | 345 |
|
346 | 346 |
sort.Strings(actual) |
347 | 347 |
sort.Strings(expected) |
... | ... |
@@ -7,6 +7,7 @@ import ( |
7 | 7 |
"fmt" |
8 | 8 |
"os" |
9 | 9 |
"os/exec" |
10 |
+ "strings" |
|
10 | 11 |
"testing" |
11 | 12 |
|
12 | 13 |
"github.com/docker/docker/vendor/src/github.com/kr/pty" |
... | ... |
@@ -20,7 +21,7 @@ func TestSaveAndLoadRepoStdout(t *testing.T) { |
20 | 20 |
t.Fatalf("failed to create a container: %s, %v", out, err) |
21 | 21 |
} |
22 | 22 |
|
23 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
23 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
24 | 24 |
|
25 | 25 |
repoName := "foobar-save-load-test" |
26 | 26 |
|
... | ... |
@@ -49,7 +49,7 @@ func TestStartAttachCorrectExitCode(t *testing.T) { |
49 | 49 |
t.Fatalf("failed to run container: %v, output: %q", err, out) |
50 | 50 |
} |
51 | 51 |
|
52 |
- out = stripTrailingCharacters(out) |
|
52 |
+ out = strings.TrimSpace(out) |
|
53 | 53 |
|
54 | 54 |
// make sure the container has exited before trying the "start -a" |
55 | 55 |
waitCmd := exec.Command(dockerBinary, "wait", out) |
... | ... |
@@ -32,7 +32,7 @@ func TestTagUnprefixedRepoByID(t *testing.T) { |
32 | 32 |
t.Fatalf("failed to get the image ID of busybox: %s, %v", out, err) |
33 | 33 |
} |
34 | 34 |
|
35 |
- cleanedImageID := stripTrailingCharacters(out) |
|
35 |
+ cleanedImageID := strings.TrimSpace(out) |
|
36 | 36 |
tagCmd := exec.Command(dockerBinary, "tag", cleanedImageID, "testfoobarbaz") |
37 | 37 |
if out, _, err = runCommandWithOutput(tagCmd); err != nil { |
38 | 38 |
t.Fatal(out, err) |
... | ... |
@@ -13,7 +13,7 @@ func TestTopMultipleArgs(t *testing.T) { |
13 | 13 |
t.Fatalf("failed to start the container: %s, %v", out, err) |
14 | 14 |
} |
15 | 15 |
|
16 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
16 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
17 | 17 |
defer deleteContainer(cleanedContainerID) |
18 | 18 |
|
19 | 19 |
topCmd := exec.Command(dockerBinary, "top", cleanedContainerID, "-o", "pid") |
... | ... |
@@ -36,7 +36,7 @@ func TestTopNonPrivileged(t *testing.T) { |
36 | 36 |
t.Fatalf("failed to start the container: %s, %v", out, err) |
37 | 37 |
} |
38 | 38 |
|
39 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
39 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
40 | 40 |
|
41 | 41 |
topCmd := exec.Command(dockerBinary, "top", cleanedContainerID) |
42 | 42 |
out1, _, err := runCommandWithOutput(topCmd) |
... | ... |
@@ -75,7 +75,7 @@ func TestTopPrivileged(t *testing.T) { |
75 | 75 |
t.Fatalf("failed to start the container: %s, %v", out, err) |
76 | 76 |
} |
77 | 77 |
|
78 |
- cleanedContainerID := stripTrailingCharacters(out) |
|
78 |
+ cleanedContainerID := strings.TrimSpace(out) |
|
79 | 79 |
|
80 | 80 |
topCmd := exec.Command(dockerBinary, "top", cleanedContainerID) |
81 | 81 |
out1, _, err := runCommandWithOutput(topCmd) |
... | ... |
@@ -2,6 +2,7 @@ package main |
2 | 2 |
|
3 | 3 |
import ( |
4 | 4 |
"os/exec" |
5 |
+ "strings" |
|
5 | 6 |
"testing" |
6 | 7 |
"time" |
7 | 8 |
) |
... | ... |
@@ -15,7 +16,7 @@ func TestWaitNonBlockedExitZero(t *testing.T) { |
15 | 15 |
if err != nil { |
16 | 16 |
t.Fatal(out, err) |
17 | 17 |
} |
18 |
- containerID := stripTrailingCharacters(out) |
|
18 |
+ containerID := strings.TrimSpace(out) |
|
19 | 19 |
|
20 | 20 |
status := "true" |
21 | 21 |
for i := 0; status != "false"; i++ { |
... | ... |
@@ -24,7 +25,7 @@ func TestWaitNonBlockedExitZero(t *testing.T) { |
24 | 24 |
if err != nil { |
25 | 25 |
t.Fatal(status, err) |
26 | 26 |
} |
27 |
- status = stripTrailingCharacters(status) |
|
27 |
+ status = strings.TrimSpace(status) |
|
28 | 28 |
|
29 | 29 |
time.Sleep(time.Second) |
30 | 30 |
if i >= 60 { |
... | ... |
@@ -35,7 +36,7 @@ func TestWaitNonBlockedExitZero(t *testing.T) { |
35 | 35 |
runCmd = exec.Command(dockerBinary, "wait", containerID) |
36 | 36 |
out, _, err = runCommandWithOutput(runCmd) |
37 | 37 |
|
38 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
38 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
39 | 39 |
t.Fatal("failed to set up container", out, err) |
40 | 40 |
} |
41 | 41 |
|
... | ... |
@@ -51,12 +52,12 @@ func TestWaitBlockedExitZero(t *testing.T) { |
51 | 51 |
if err != nil { |
52 | 52 |
t.Fatal(out, err) |
53 | 53 |
} |
54 |
- containerID := stripTrailingCharacters(out) |
|
54 |
+ containerID := strings.TrimSpace(out) |
|
55 | 55 |
|
56 | 56 |
runCmd = exec.Command(dockerBinary, "wait", containerID) |
57 | 57 |
out, _, err = runCommandWithOutput(runCmd) |
58 | 58 |
|
59 |
- if err != nil || stripTrailingCharacters(out) != "0" { |
|
59 |
+ if err != nil || strings.TrimSpace(out) != "0" { |
|
60 | 60 |
t.Fatal("failed to set up container", out, err) |
61 | 61 |
} |
62 | 62 |
|
... | ... |
@@ -72,7 +73,7 @@ func TestWaitNonBlockedExitRandom(t *testing.T) { |
72 | 72 |
if err != nil { |
73 | 73 |
t.Fatal(out, err) |
74 | 74 |
} |
75 |
- containerID := stripTrailingCharacters(out) |
|
75 |
+ containerID := strings.TrimSpace(out) |
|
76 | 76 |
|
77 | 77 |
status := "true" |
78 | 78 |
for i := 0; status != "false"; i++ { |
... | ... |
@@ -81,7 +82,7 @@ func TestWaitNonBlockedExitRandom(t *testing.T) { |
81 | 81 |
if err != nil { |
82 | 82 |
t.Fatal(status, err) |
83 | 83 |
} |
84 |
- status = stripTrailingCharacters(status) |
|
84 |
+ status = strings.TrimSpace(status) |
|
85 | 85 |
|
86 | 86 |
time.Sleep(time.Second) |
87 | 87 |
if i >= 60 { |
... | ... |
@@ -92,7 +93,7 @@ func TestWaitNonBlockedExitRandom(t *testing.T) { |
92 | 92 |
runCmd = exec.Command(dockerBinary, "wait", containerID) |
93 | 93 |
out, _, err = runCommandWithOutput(runCmd) |
94 | 94 |
|
95 |
- if err != nil || stripTrailingCharacters(out) != "99" { |
|
95 |
+ if err != nil || strings.TrimSpace(out) != "99" { |
|
96 | 96 |
t.Fatal("failed to set up container", out, err) |
97 | 97 |
} |
98 | 98 |
|
... | ... |
@@ -108,12 +109,12 @@ func TestWaitBlockedExitRandom(t *testing.T) { |
108 | 108 |
if err != nil { |
109 | 109 |
t.Fatal(out, err) |
110 | 110 |
} |
111 |
- containerID := stripTrailingCharacters(out) |
|
111 |
+ containerID := strings.TrimSpace(out) |
|
112 | 112 |
|
113 | 113 |
runCmd = exec.Command(dockerBinary, "wait", containerID) |
114 | 114 |
out, _, err = runCommandWithOutput(runCmd) |
115 | 115 |
|
116 |
- if err != nil || stripTrailingCharacters(out) != "99" { |
|
116 |
+ if err != nil || strings.TrimSpace(out) != "99" { |
|
117 | 117 |
t.Fatal("failed to set up container", out, err) |
118 | 118 |
} |
119 | 119 |
|
... | ... |
@@ -526,7 +526,7 @@ func getContainerCount() (int, error) { |
526 | 526 |
lines := strings.Split(out, "\n") |
527 | 527 |
for _, line := range lines { |
528 | 528 |
if strings.Contains(line, containers) { |
529 |
- output := stripTrailingCharacters(line) |
|
529 |
+ output := strings.TrimSpace(line) |
|
530 | 530 |
output = strings.TrimLeft(output, containers) |
531 | 531 |
output = strings.Trim(output, " ") |
532 | 532 |
containerCount, err := strconv.Atoi(output) |
... | ... |
@@ -169,10 +169,6 @@ func logDone(message string) { |
169 | 169 |
fmt.Printf("[PASSED]: %.69s\n", message) |
170 | 170 |
} |
171 | 171 |
|
172 |
-func stripTrailingCharacters(target string) string { |
|
173 |
- return strings.TrimSpace(target) |
|
174 |
-} |
|
175 |
- |
|
176 | 172 |
func unmarshalJSON(data []byte, result interface{}) error { |
177 | 173 |
err := json.Unmarshal(data, result) |
178 | 174 |
if err != nil { |