Skip to content

Commit 475c653

Browse files
committed
Remove stripTrailingCharacters from tests
This was just an alias to `strings.TrimSpace` Signed-off-by: Brian Goff <[email protected]>
1 parent a73b735 commit 475c653

31 files changed

Lines changed: 130 additions & 129 deletions

‎integration-cli/docker_api_attach_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bytes"
55
"os/exec"
6+
"strings"
67
"testing"
78
"time"
89

@@ -22,7 +23,7 @@ func TestGetContainersAttachWebsocket(t *testing.T) {
2223
t.Fatal(err)
2324
}
2425

25-
cleanedContainerID := stripTrailingCharacters(out)
26+
cleanedContainerID := strings.TrimSpace(out)
2627
config, err := websocket.NewConfig(
2728
"/containers/"+cleanedContainerID+"/attach/ws?stream=1&stdin=1&stdout=1&stderr=1",
2829
"http://localhost",

‎integration-cli/docker_api_inspect_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"os/exec"
6+
"strings"
67
"testing"
78
)
89

@@ -15,7 +16,7 @@ func TestInspectApiContainerResponse(t *testing.T) {
1516
t.Fatalf("failed to create a container: %s, %v", out, err)
1617
}
1718

18-
cleanedContainerID := stripTrailingCharacters(out)
19+
cleanedContainerID := strings.TrimSpace(out)
1920

2021
// test on json marshal version
2122
// and latest version

‎integration-cli/docker_api_resize_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestResizeApiResponse(t *testing.T) {
1313
t.Fatalf(out, err)
1414
}
1515
defer deleteAllContainers()
16-
cleanedContainerID := stripTrailingCharacters(out)
16+
cleanedContainerID := strings.TrimSpace(out)
1717

1818
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
1919
_, err = sockRequest("POST", endpoint, nil)
@@ -31,7 +31,7 @@ func TestResizeApiResponseWhenContainerNotStarted(t *testing.T) {
3131
t.Fatalf(out, err)
3232
}
3333
defer deleteAllContainers()
34-
cleanedContainerID := stripTrailingCharacters(out)
34+
cleanedContainerID := strings.TrimSpace(out)
3535

3636
// make sure the exited cintainer is not running
3737
runCmd = exec.Command(dockerBinary, "wait", cleanedContainerID)

‎integration-cli/docker_cli_attach_unix_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestAttachClosedOnContainerStop(t *testing.T) {
2121
t.Fatalf("failed to start container: %v (%v)", out, err)
2222
}
2323

24-
id := stripTrailingCharacters(out)
24+
id := strings.TrimSpace(out)
2525
if err := waitRun(id); err != nil {
2626
t.Fatal(err)
2727
}

‎integration-cli/docker_cli_build_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ func TestBuildOnBuildForbiddenMaintainerInSourceImage(t *testing.T) {
492492
t.Fatal(out, err)
493493
}
494494

495-
cleanedContainerID := stripTrailingCharacters(out)
495+
cleanedContainerID := strings.TrimSpace(out)
496496

497497
commitCmd := exec.Command(dockerBinary, "commit", "--run", "{\"OnBuild\":[\"MAINTAINER docker.io\"]}", cleanedContainerID, "onbuild")
498498

@@ -526,7 +526,7 @@ func TestBuildOnBuildForbiddenFromInSourceImage(t *testing.T) {
526526
t.Fatal(out, err)
527527
}
528528

529-
cleanedContainerID := stripTrailingCharacters(out)
529+
cleanedContainerID := strings.TrimSpace(out)
530530

531531
commitCmd := exec.Command(dockerBinary, "commit", "--run", "{\"OnBuild\":[\"FROM busybox\"]}", cleanedContainerID, "onbuild")
532532

@@ -560,7 +560,7 @@ func TestBuildOnBuildForbiddenChainedInSourceImage(t *testing.T) {
560560
t.Fatal(out, err)
561561
}
562562

563-
cleanedContainerID := stripTrailingCharacters(out)
563+
cleanedContainerID := strings.TrimSpace(out)
564564

565565
commitCmd := exec.Command(dockerBinary, "commit", "--run", "{\"OnBuild\":[\"ONBUILD RUN ls\"]}", cleanedContainerID, "onbuild")
566566

@@ -5534,7 +5534,7 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) {
55345534
t.Fatal(err, out)
55355535
}
55365536

5537-
cID := stripTrailingCharacters(out)
5537+
cID := strings.TrimSpace(out)
55385538

55395539
type hostConfig struct {
55405540
Memory float64 // Use float64 here since the json decoder sees it that way

‎integration-cli/docker_cli_commit_test.go‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestCommitAfterContainerIsDone(t *testing.T) {
1313
t.Fatalf("failed to run container: %s, %v", out, err)
1414
}
1515

16-
cleanedContainerID := stripTrailingCharacters(out)
16+
cleanedContainerID := strings.TrimSpace(out)
1717

1818
waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
1919
if _, _, err = runCommandWithOutput(waitCmd); err != nil {
@@ -26,7 +26,7 @@ func TestCommitAfterContainerIsDone(t *testing.T) {
2626
t.Fatalf("failed to commit container to image: %s, %v", out, err)
2727
}
2828

29-
cleanedImageID := stripTrailingCharacters(out)
29+
cleanedImageID := strings.TrimSpace(out)
3030

3131
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
3232
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
@@ -46,7 +46,7 @@ func TestCommitWithoutPause(t *testing.T) {
4646
t.Fatalf("failed to run container: %s, %v", out, err)
4747
}
4848

49-
cleanedContainerID := stripTrailingCharacters(out)
49+
cleanedContainerID := strings.TrimSpace(out)
5050

5151
waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
5252
if _, _, err = runCommandWithOutput(waitCmd); err != nil {
@@ -59,7 +59,7 @@ func TestCommitWithoutPause(t *testing.T) {
5959
t.Fatalf("failed to commit container to image: %s, %v", out, err)
6060
}
6161

62-
cleanedImageID := stripTrailingCharacters(out)
62+
cleanedImageID := strings.TrimSpace(out)
6363

6464
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
6565
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
@@ -82,7 +82,7 @@ func TestCommitPausedContainer(t *testing.T) {
8282
t.Fatalf("failed to run container: %v, output: %q", err, out)
8383
}
8484

85-
cleanedContainerID := stripTrailingCharacters(out)
85+
cleanedContainerID := strings.TrimSpace(out)
8686
cmd = exec.Command(dockerBinary, "pause", cleanedContainerID)
8787
out, _, _, err = runCommandWithStdoutStderr(cmd)
8888
if err != nil {
@@ -94,7 +94,7 @@ func TestCommitPausedContainer(t *testing.T) {
9494
if err != nil {
9595
t.Fatalf("failed to commit container to image: %s, %v", out, err)
9696
}
97-
cleanedImageID := stripTrailingCharacters(out)
97+
cleanedImageID := strings.TrimSpace(out)
9898
defer deleteImages(cleanedImageID)
9999

100100
cmd = exec.Command(dockerBinary, "inspect", "-f", "{{.State.Paused}}", cleanedContainerID)

‎integration-cli/docker_cli_cp_test.go‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ func TestCpGarbagePath(t *testing.T) {
3030
t.Fatal("failed to create a container", out, err)
3131
}
3232

33-
cleanedContainerID := stripTrailingCharacters(out)
33+
cleanedContainerID := strings.TrimSpace(out)
3434
defer deleteContainer(cleanedContainerID)
3535

3636
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
37-
if err != nil || stripTrailingCharacters(out) != "0" {
37+
if err != nil || strings.TrimSpace(out) != "0" {
3838
t.Fatal("failed to set up container", out, err)
3939
}
4040

@@ -92,11 +92,11 @@ func TestCpRelativePath(t *testing.T) {
9292
t.Fatal("failed to create a container", out, err)
9393
}
9494

95-
cleanedContainerID := stripTrailingCharacters(out)
95+
cleanedContainerID := strings.TrimSpace(out)
9696
defer deleteContainer(cleanedContainerID)
9797

9898
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
99-
if err != nil || stripTrailingCharacters(out) != "0" {
99+
if err != nil || strings.TrimSpace(out) != "0" {
100100
t.Fatal("failed to set up container", out, err)
101101
}
102102

@@ -162,11 +162,11 @@ func TestCpAbsolutePath(t *testing.T) {
162162
t.Fatal("failed to create a container", out, err)
163163
}
164164

165-
cleanedContainerID := stripTrailingCharacters(out)
165+
cleanedContainerID := strings.TrimSpace(out)
166166
defer deleteContainer(cleanedContainerID)
167167

168168
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
169-
if err != nil || stripTrailingCharacters(out) != "0" {
169+
if err != nil || strings.TrimSpace(out) != "0" {
170170
t.Fatal("failed to set up container", out, err)
171171
}
172172

@@ -226,11 +226,11 @@ func TestCpAbsoluteSymlink(t *testing.T) {
226226
t.Fatal("failed to create a container", out, err)
227227
}
228228

229-
cleanedContainerID := stripTrailingCharacters(out)
229+
cleanedContainerID := strings.TrimSpace(out)
230230
defer deleteContainer(cleanedContainerID)
231231

232232
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
233-
if err != nil || stripTrailingCharacters(out) != "0" {
233+
if err != nil || strings.TrimSpace(out) != "0" {
234234
t.Fatal("failed to set up container", out, err)
235235
}
236236

@@ -290,11 +290,11 @@ func TestCpSymlinkComponent(t *testing.T) {
290290
t.Fatal("failed to create a container", out, err)
291291
}
292292

293-
cleanedContainerID := stripTrailingCharacters(out)
293+
cleanedContainerID := strings.TrimSpace(out)
294294
defer deleteContainer(cleanedContainerID)
295295

296296
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
297-
if err != nil || stripTrailingCharacters(out) != "0" {
297+
if err != nil || strings.TrimSpace(out) != "0" {
298298
t.Fatal("failed to set up container", out, err)
299299
}
300300

@@ -355,11 +355,11 @@ func TestCpUnprivilegedUser(t *testing.T) {
355355
t.Fatal("failed to create a container", out, err)
356356
}
357357

358-
cleanedContainerID := stripTrailingCharacters(out)
358+
cleanedContainerID := strings.TrimSpace(out)
359359
defer deleteContainer(cleanedContainerID)
360360

361361
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
362-
if err != nil || stripTrailingCharacters(out) != "0" {
362+
if err != nil || strings.TrimSpace(out) != "0" {
363363
t.Fatal("failed to set up container", out, err)
364364
}
365365

@@ -398,11 +398,11 @@ func TestCpSpecialFiles(t *testing.T) {
398398
t.Fatal("failed to create a container", out, err)
399399
}
400400

401-
cleanedContainerID := stripTrailingCharacters(out)
401+
cleanedContainerID := strings.TrimSpace(out)
402402
defer deleteContainer(cleanedContainerID)
403403

404404
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
405-
if err != nil || stripTrailingCharacters(out) != "0" {
405+
if err != nil || strings.TrimSpace(out) != "0" {
406406
t.Fatal("failed to set up container", out, err)
407407
}
408408

@@ -471,11 +471,11 @@ func TestCpVolumePath(t *testing.T) {
471471
t.Fatal("failed to create a container", out, err)
472472
}
473473

474-
cleanedContainerID := stripTrailingCharacters(out)
474+
cleanedContainerID := strings.TrimSpace(out)
475475
defer deleteContainer(cleanedContainerID)
476476

477477
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
478-
if err != nil || stripTrailingCharacters(out) != "0" {
478+
if err != nil || strings.TrimSpace(out) != "0" {
479479
t.Fatal("failed to set up container", out, err)
480480
}
481481

@@ -562,11 +562,11 @@ func TestCpToDot(t *testing.T) {
562562
t.Fatal("failed to create a container", out, err)
563563
}
564564

565-
cleanedContainerID := stripTrailingCharacters(out)
565+
cleanedContainerID := strings.TrimSpace(out)
566566
defer deleteContainer(cleanedContainerID)
567567

568568
out, _, err = dockerCmd(t, "wait", cleanedContainerID)
569-
if err != nil || stripTrailingCharacters(out) != "0" {
569+
if err != nil || strings.TrimSpace(out) != "0" {
570570
t.Fatal("failed to set up container", out, err)
571571
}
572572

@@ -600,11 +600,11 @@ func TestCpToStdout(t *testing.T) {
600600
t.Fatalf("failed to create a container:%s\n%s", out, err)
601601
}
602602

603-
cID := stripTrailingCharacters(out)
603+
cID := strings.TrimSpace(out)
604604
defer deleteContainer(cID)
605605

606606
out, _, err = dockerCmd(t, "wait", cID)
607-
if err != nil || stripTrailingCharacters(out) != "0" {
607+
if err != nil || strings.TrimSpace(out) != "0" {
608608
t.Fatalf("failed to set up container:%s\n%s", out, err)
609609
}
610610

‎integration-cli/docker_cli_create_test.go‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"os/exec"
77
"reflect"
8+
"strings"
89
"testing"
910
"time"
1011

@@ -21,7 +22,7 @@ func TestCreateArgs(t *testing.T) {
2122
t.Fatal(out, err)
2223
}
2324

24-
cleanedContainerID := stripTrailingCharacters(out)
25+
cleanedContainerID := strings.TrimSpace(out)
2526

2627
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
2728
out, _, err = runCommandWithOutput(inspectCmd)
@@ -73,7 +74,7 @@ func TestCreateHostConfig(t *testing.T) {
7374
t.Fatal(out, err)
7475
}
7576

76-
cleanedContainerID := stripTrailingCharacters(out)
77+
cleanedContainerID := strings.TrimSpace(out)
7778

7879
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
7980
out, _, err = runCommandWithOutput(inspectCmd)
@@ -114,7 +115,7 @@ func TestCreateWithPortRange(t *testing.T) {
114115
t.Fatal(out, err)
115116
}
116117

117-
cleanedContainerID := stripTrailingCharacters(out)
118+
cleanedContainerID := strings.TrimSpace(out)
118119

119120
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
120121
out, _, err = runCommandWithOutput(inspectCmd)
@@ -163,7 +164,7 @@ func TestCreateWithiLargePortRange(t *testing.T) {
163164
t.Fatal(out, err)
164165
}
165166

166-
cleanedContainerID := stripTrailingCharacters(out)
167+
cleanedContainerID := strings.TrimSpace(out)
167168

168169
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
169170
out, _, err = runCommandWithOutput(inspectCmd)
@@ -213,7 +214,7 @@ func TestCreateEchoStdout(t *testing.T) {
213214
t.Fatal(out, err)
214215
}
215216

216-
cleanedContainerID := stripTrailingCharacters(out)
217+
cleanedContainerID := strings.TrimSpace(out)
217218

218219
runCmd = exec.Command(dockerBinary, "start", "-ai", cleanedContainerID)
219220
out, _, _, err = runCommandWithStdoutStderr(runCmd)

‎integration-cli/docker_cli_diff_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestDiffFilenameShownInOutput(t *testing.T) {
1515
t.Fatalf("failed to start the container: %s, %v", out, err)
1616
}
1717

18-
cleanCID := stripTrailingCharacters(out)
18+
cleanCID := strings.TrimSpace(out)
1919

2020
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
2121
out, _, err = runCommandWithOutput(diffCmd)
@@ -52,7 +52,7 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
5252
t.Fatal(out, err)
5353
}
5454

55-
cleanCID := stripTrailingCharacters(out)
55+
cleanCID := strings.TrimSpace(out)
5656

5757
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
5858
out, _, err = runCommandWithOutput(diffCmd)
@@ -79,7 +79,7 @@ func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
7979
t.Fatal(out, err)
8080
}
8181

82-
cleanCID := stripTrailingCharacters(out)
82+
cleanCID := strings.TrimSpace(out)
8383

8484
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
8585
out, _, err = runCommandWithOutput(diffCmd)

0 commit comments

Comments
 (0)