mirror of
https://github.com/moby/moby.git
synced 2026-08-04 23:21:00 +00:00
fix thelper linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -94,21 +94,21 @@ func defaultMkContentCommand() string {
|
||||
return mkFilesCommand(defaultFileData)
|
||||
}
|
||||
|
||||
func makeTestContentInDir(c *testing.T, dir string) {
|
||||
c.Helper()
|
||||
func makeTestContentInDir(t *testing.T, dir string) {
|
||||
t.Helper()
|
||||
for _, fd := range defaultFileData {
|
||||
path := filepath.Join(dir, filepath.FromSlash(fd.path))
|
||||
switch fd.filetype {
|
||||
case ftRegular:
|
||||
assert.NilError(c, os.WriteFile(path, []byte(fd.contents+"\n"), os.FileMode(fd.mode)))
|
||||
assert.NilError(t, os.WriteFile(path, []byte(fd.contents+"\n"), os.FileMode(fd.mode)))
|
||||
case ftDir:
|
||||
assert.NilError(c, os.Mkdir(path, os.FileMode(fd.mode)))
|
||||
assert.NilError(t, os.Mkdir(path, os.FileMode(fd.mode)))
|
||||
case ftSymlink:
|
||||
assert.NilError(c, os.Symlink(fd.contents, path))
|
||||
assert.NilError(t, os.Symlink(fd.contents, path))
|
||||
}
|
||||
|
||||
if fd.filetype != ftSymlink && runtime.GOOS != "windows" {
|
||||
assert.NilError(c, os.Chown(path, fd.uid, fd.gid))
|
||||
assert.NilError(t, os.Chown(path, fd.uid, fd.gid))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,8 +121,8 @@ type testContainerOptions struct {
|
||||
command string
|
||||
}
|
||||
|
||||
func makeTestContainer(c *testing.T, options testContainerOptions) (containerID string) {
|
||||
c.Helper()
|
||||
func makeTestContainer(t *testing.T, options testContainerOptions) (containerID string) {
|
||||
t.Helper()
|
||||
if options.addContent {
|
||||
mkContentCmd := defaultMkContentCommand()
|
||||
if options.command == "" {
|
||||
@@ -152,17 +152,17 @@ func makeTestContainer(c *testing.T, options testContainerOptions) (containerID
|
||||
|
||||
args = append(args, "busybox", "/bin/sh", "-c", options.command)
|
||||
|
||||
out := cli.DockerCmd(c, args...).Combined()
|
||||
out := cli.DockerCmd(t, args...).Combined()
|
||||
|
||||
containerID = strings.TrimSpace(out)
|
||||
|
||||
out = cli.DockerCmd(c, "wait", containerID).Combined()
|
||||
out = cli.DockerCmd(t, "wait", containerID).Combined()
|
||||
|
||||
exitCode := strings.TrimSpace(out)
|
||||
if exitCode != "0" {
|
||||
out = cli.DockerCmd(c, "logs", containerID).Combined()
|
||||
out = cli.DockerCmd(t, "logs", containerID).Combined()
|
||||
}
|
||||
assert.Equal(c, exitCode, "0", "failed to make test container: %s", out)
|
||||
assert.Equal(t, exitCode, "0", "failed to make test container: %s", out)
|
||||
|
||||
return containerID
|
||||
}
|
||||
@@ -192,8 +192,8 @@ func containerCpPathTrailingSep(containerID string, pathElements ...string) stri
|
||||
return fmt.Sprintf("%s/", containerCpPath(containerID, pathElements...))
|
||||
}
|
||||
|
||||
func runDockerCp(c *testing.T, src, dst string) error {
|
||||
c.Helper()
|
||||
func runDockerCp(t *testing.T, src, dst string) error {
|
||||
t.Helper()
|
||||
|
||||
args := []string{"cp", src, dst}
|
||||
if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, args...)); err != nil {
|
||||
@@ -202,8 +202,8 @@ func runDockerCp(c *testing.T, src, dst string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func startContainerGetOutput(c *testing.T, containerID string) (string, error) {
|
||||
c.Helper()
|
||||
func startContainerGetOutput(t *testing.T, containerID string) (string, error) {
|
||||
t.Helper()
|
||||
|
||||
args := []string{"start", "-a", containerID}
|
||||
|
||||
@@ -215,13 +215,13 @@ func startContainerGetOutput(c *testing.T, containerID string) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func getTestDir(c *testing.T, label string) (tmpDir string) {
|
||||
c.Helper()
|
||||
func getTestDir(t *testing.T, label string) (tmpDir string) {
|
||||
t.Helper()
|
||||
var err error
|
||||
|
||||
tmpDir, err = os.MkdirTemp("", label)
|
||||
// unable to make temporary directory
|
||||
assert.NilError(c, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
return tmpDir
|
||||
}
|
||||
@@ -234,8 +234,8 @@ func isCpCannotCopyDir(err error) is.Comparison {
|
||||
return is.ErrorContains(err, archive.ErrCannotCopyDir.Error())
|
||||
}
|
||||
|
||||
func fileContentEquals(c *testing.T, filename, contents string) error {
|
||||
c.Helper()
|
||||
func fileContentEquals(t *testing.T, filename, contents string) error {
|
||||
t.Helper()
|
||||
|
||||
fileBytes, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
@@ -254,8 +254,8 @@ func fileContentEquals(c *testing.T, filename, contents string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func symlinkTargetEquals(c *testing.T, symlink, expectedTarget string) error {
|
||||
c.Helper()
|
||||
func symlinkTargetEquals(t *testing.T, symlink, expectedTarget string) error {
|
||||
t.Helper()
|
||||
|
||||
actualTarget, err := os.Readlink(symlink)
|
||||
if err != nil {
|
||||
@@ -269,10 +269,10 @@ func symlinkTargetEquals(c *testing.T, symlink, expectedTarget string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func containerStartOutputEquals(c *testing.T, containerID, contents string) error {
|
||||
c.Helper()
|
||||
func containerStartOutputEquals(t *testing.T, containerID, contents string) error {
|
||||
t.Helper()
|
||||
|
||||
out, err := startContainerGetOutput(c, containerID)
|
||||
out, err := startContainerGetOutput(t, containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user