浏览代码

intgration-cli: fix formatting

Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit cc01289792d918856d0c1a0cf38008f32d3d5bc7)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Tibor Vass 5 年之前
父节点
当前提交
d98c74d38d

+ 2 - 12
integration-cli/docker_api_containers_test.go

@@ -1064,12 +1064,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *testing.T)
 	}
 	b, err := request.ReadBody(body)
 	assert.NilError(c, err)
-	assert.Assert(c, is.Regexp("^"+
-
-		"Path cannot be empty\n"+
-		"$",
-
-		string(b)))
+	assert.Assert(c, is.Regexp("^Path cannot be empty\n$", string(b)))
 
 }
 
@@ -1091,12 +1086,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing.
 	}
 	b, err := request.ReadBody(body)
 	assert.NilError(c, err)
-	assert.Assert(c, is.Regexp("^"+
-
-		("Could not find the file /notexist in container "+name+"\n")+
-		"$",
-
-		string(b)))
+	assert.Assert(c, is.Regexp("^Could not find the file /notexist in container "+name+"\n$", string(b)))
 
 }
 

+ 5 - 30
integration-cli/docker_cli_build_test.go

@@ -4799,12 +4799,7 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
 	cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
 
 	out := cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
-	assert.Assert(c, cmp.Regexp("^"+
-
-		"bar"+
-		"$",
-
-		out))
+	assert.Assert(c, cmp.Regexp("^bar$", out))
 
 	// change target file should invalidate cache
 	err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
@@ -4813,12 +4808,7 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
 	result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
 	assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
 	out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
-	assert.Assert(c, cmp.Regexp("^"+
-
-		"baz"+
-		"$",
-
-		out))
+	assert.Assert(c, cmp.Regexp("^baz$", out))
 
 }
 
@@ -4840,12 +4830,7 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
 	cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
 
 	out := cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined()
-	assert.Assert(c, cmp.Regexp("^"+
-
-		"barbaz"+
-		"$",
-
-		out))
+	assert.Assert(c, cmp.Regexp("^barbaz$", out))
 
 	// change target file should invalidate cache
 	err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0644)
@@ -4854,12 +4839,7 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
 	result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
 	assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
 	out = cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined()
-	assert.Assert(c, cmp.Regexp("^"+
-
-		"barbax"+
-		"$",
-
-		out))
+	assert.Assert(c, cmp.Regexp("^barbax$", out))
 
 }
 
@@ -4882,12 +4862,7 @@ func (s *DockerSuite) TestBuildSymlinkBasename(c *testing.T) {
 	cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
 
 	out := cli.DockerCmd(c, "run", "--rm", name, "cat", "asymlink").Combined()
-	assert.Assert(c, cmp.Regexp("^"+
-
-		"bar"+
-		"$",
-
-		out))
+	assert.Assert(c, cmp.Regexp("^bar$", out))
 
 }
 

+ 1 - 5
integration-cli/docker_cli_history_test.go

@@ -115,11 +115,7 @@ func (s *DockerSuite) TestHistoryHumanOptionTrue(c *testing.T) {
 			endIndex = len(lines[i])
 		}
 		sizeString := lines[i][startIndex:endIndex]
-		assert.Assert(c, cmp.Regexp("^"+
-
-			humanSizeRegexRaw+
-			"$",
-
+		assert.Assert(c, cmp.Regexp("^"+humanSizeRegexRaw+"$",
 			strings.TrimSpace(sizeString)), fmt.Sprintf("The size '%s' was not in human format", sizeString))
 	}
 }

+ 3 - 13
integration-cli/docker_cli_images_test.go

@@ -90,21 +90,11 @@ func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) {
 
 	out, _ := dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match")
 	out = strings.TrimSpace(out)
-	assert.Assert(c, is.Regexp("^"+
+	assert.Assert(c, is.Regexp(fmt.Sprintf("^[\\s\\w:]*%s[\\s\\w:]*$", image1ID), out))
 
-		fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID)+
-		"$",
+	assert.Assert(c, is.Regexp(fmt.Sprintf("^[\\s\\w:]*%s[\\s\\w:]*$", image2ID), out))
 
-		out))
-
-	assert.Assert(c, is.Regexp("^"+
-
-		fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID)+
-		"$",
-
-		out))
-
-	assert.Assert(c, !is.Regexp("^"+fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image3ID)+"$", out)().Success())
+	assert.Assert(c, !is.Regexp(fmt.Sprintf("^[\\s\\w:]*%s[\\s\\w:]*$", image3ID), out)().Success())
 
 	out, _ = dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match=me too")
 	out = strings.TrimSpace(out)

+ 1 - 7
integration-cli/docker_cli_links_test.go

@@ -229,13 +229,7 @@ func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *testing.T) {
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
 	out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts")
 	// /etc/hosts should be a regular file
-	assert.Assert(c, cmp.Regexp("^"+
-
-		"^-.+\n"+
-		"$",
-
-		out))
-
+	assert.Assert(c, cmp.Regexp("^-.+\n$", out))
 }
 
 func (s *DockerSuite) TestLinksMultipleWithSameName(c *testing.T) {