integration/container: format code with gofumpt
Formatting the code with https://github.com/mvdan/gofumpt Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
846bcd7dd1
commit
89a4e6b889
7 changed files with 24 additions and 22 deletions
|
@ -95,7 +95,7 @@ func TestCopyEmptyFile(t *testing.T) {
|
|||
func makeEmptyArchive(t *testing.T) (string, io.ReadCloser) {
|
||||
tmpDir := t.TempDir()
|
||||
srcPath := filepath.Join(tmpDir, "empty-file.txt")
|
||||
err := os.WriteFile(srcPath, []byte(""), 0400)
|
||||
err := os.WriteFile(srcPath, []byte(""), 0o400)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// TODO(thaJeztah) Add utilities to the client to make steps below less complicated.
|
||||
|
|
|
@ -176,6 +176,7 @@ func TestCreateTmpfsMountsTarget(t *testing.T) {
|
|||
assert.Check(t, errdefs.IsInvalidParameter(err))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateWithCustomMaskedPaths(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType != "linux")
|
||||
|
||||
|
|
|
@ -114,15 +114,16 @@ func TestWindowsDevices(t *testing.T) {
|
|||
|
||||
// /Windows/System32/HostDriverStore is mounted from the host when class GUID 5B45201D-F2F2-4F3B-85BB-30FF1F953599
|
||||
// is mounted. See `C:\windows\System32\containers\devices.def` on a Windows host for (slightly more) details.
|
||||
res, err := container.Exec(ctx, client, id, []string{"sh", "-c",
|
||||
"ls -d /Windows/System32/HostDriverStore/* | grep /Windows/System32/HostDriverStore/FileRepository"})
|
||||
res, err := container.Exec(ctx, client, id, []string{
|
||||
"sh", "-c",
|
||||
"ls -d /Windows/System32/HostDriverStore/* | grep /Windows/System32/HostDriverStore/FileRepository",
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, d.expectedExitCode, res.ExitCode)
|
||||
if d.expectedExitCode == 0 {
|
||||
assert.Equal(t, d.expectedStdout, strings.TrimSpace(res.Stdout()))
|
||||
assert.Equal(t, d.expectedStderr, strings.TrimSpace(res.Stderr()))
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
|
|||
|
||||
ctx := context.Background()
|
||||
|
||||
tmpDir := fs.NewDir(t, "network-file-mounts", fs.WithMode(0755), fs.WithFile("nwfile", "network file bind mount", fs.WithMode(0644)))
|
||||
tmpDir := fs.NewDir(t, "network-file-mounts", fs.WithMode(0o755), fs.WithFile("nwfile", "network file bind mount", fs.WithMode(0o644)))
|
||||
defer tmpDir.Remove()
|
||||
|
||||
tmpNWFileMount := tmpDir.Join("nwfile")
|
||||
|
@ -179,7 +179,6 @@ func TestMountDaemonRoot(t *testing.T) {
|
|||
Image: "busybox",
|
||||
Cmd: []string{"true"},
|
||||
}, hc, nil, nil, "")
|
||||
|
||||
if err != nil {
|
||||
if test.expected != "" {
|
||||
t.Fatal(err)
|
||||
|
@ -222,12 +221,12 @@ func TestContainerBindMountNonRecursive(t *testing.T) {
|
|||
|
||||
defer setupTest(t)()
|
||||
|
||||
tmpDir1 := fs.NewDir(t, "tmpdir1", fs.WithMode(0755),
|
||||
fs.WithDir("mnt", fs.WithMode(0755)))
|
||||
tmpDir1 := fs.NewDir(t, "tmpdir1", fs.WithMode(0o755),
|
||||
fs.WithDir("mnt", fs.WithMode(0o755)))
|
||||
defer tmpDir1.Remove()
|
||||
tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt")
|
||||
tmpDir2 := fs.NewDir(t, "tmpdir2", fs.WithMode(0755),
|
||||
fs.WithFile("file", "should not be visible when NonRecursive", fs.WithMode(0644)))
|
||||
tmpDir2 := fs.NewDir(t, "tmpdir2", fs.WithMode(0o755),
|
||||
fs.WithFile("file", "should not be visible when NonRecursive", fs.WithMode(0o644)))
|
||||
defer tmpDir2.Remove()
|
||||
|
||||
err := mount.Mount(tmpDir2.Path(), tmpDir1Mnt, "none", "bind,ro")
|
||||
|
@ -281,8 +280,8 @@ func TestContainerVolumesMountedAsShared(t *testing.T) {
|
|||
defer setupTest(t)()
|
||||
|
||||
// Prepare a source directory to bind mount
|
||||
tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0755),
|
||||
fs.WithDir("mnt1", fs.WithMode(0755)))
|
||||
tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0o755),
|
||||
fs.WithDir("mnt1", fs.WithMode(0o755)))
|
||||
defer tmpDir1.Remove()
|
||||
tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
|
||||
|
||||
|
@ -332,15 +331,15 @@ func TestContainerVolumesMountedAsSlave(t *testing.T) {
|
|||
skip.If(t, testEnv.IsRootless, "cannot be tested because RootlessKit executes the daemon in private mount namespace (https://github.com/rootless-containers/rootlesskit/issues/97)")
|
||||
|
||||
// Prepare a source directory to bind mount
|
||||
tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0755),
|
||||
fs.WithDir("mnt1", fs.WithMode(0755)))
|
||||
tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0o755),
|
||||
fs.WithDir("mnt1", fs.WithMode(0o755)))
|
||||
defer tmpDir1.Remove()
|
||||
tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
|
||||
|
||||
// Prepare a source directory with file in it. We will bind mount this
|
||||
// directory and see if file shows up.
|
||||
tmpDir2 := fs.NewDir(t, "volume-source2", fs.WithMode(0755),
|
||||
fs.WithFile("slave-testfile", "Test", fs.WithMode(0644)))
|
||||
tmpDir2 := fs.NewDir(t, "volume-source2", fs.WithMode(0o755),
|
||||
fs.WithFile("slave-testfile", "Test", fs.WithMode(0o644)))
|
||||
defer tmpDir2.Remove()
|
||||
|
||||
// Convert this directory into a shared mount point so that we do
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestRemoveContainerWithRemovedVolume(t *testing.T) {
|
|||
|
||||
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
|
||||
|
||||
tempDir := fs.NewDir(t, "test-rm-container-with-removed-volume", fs.WithMode(0755))
|
||||
tempDir := fs.NewDir(t, "test-rm-container-with-removed-volume", fs.WithMode(0o755))
|
||||
defer tempDir.Remove()
|
||||
|
||||
cID := container.Run(ctx, t, client, container.WithCmd("true"), container.WithBind(tempDir.Path(), prefix+slash+"test"))
|
||||
|
|
|
@ -48,7 +48,8 @@ func TestDaemonRestartKillContainers(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "container with restart=always and with healthcheck",
|
||||
config: &container.Config{Image: "busybox", Cmd: []string{"top"},
|
||||
config: &container.Config{
|
||||
Image: "busybox", Cmd: []string{"top"},
|
||||
Healthcheck: &container.HealthConfig{
|
||||
Test: []string{"CMD-SHELL", "sleep 1"},
|
||||
Interval: time.Second,
|
||||
|
|
|
@ -155,15 +155,15 @@ func TestPrivilegedHostDevices(t *testing.T) {
|
|||
)
|
||||
|
||||
// Create Null devices.
|
||||
if err := system.Mknod(devTest, unix.S_IFCHR|0600, int(system.Mkdev(1, 3))); err != nil {
|
||||
if err := system.Mknod(devTest, unix.S_IFCHR|0o600, int(system.Mkdev(1, 3))); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(devTest)
|
||||
if err := os.Mkdir(filepath.Dir(devRootOnlyTest), 0700); err != nil {
|
||||
if err := os.Mkdir(filepath.Dir(devRootOnlyTest), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(filepath.Dir(devRootOnlyTest))
|
||||
if err := system.Mknod(devRootOnlyTest, unix.S_IFCHR|0600, int(system.Mkdev(1, 3))); err != nil {
|
||||
if err := system.Mknod(devRootOnlyTest, unix.S_IFCHR|0o600, int(system.Mkdev(1, 3))); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(devRootOnlyTest)
|
||||
|
@ -238,7 +238,7 @@ func TestRunWithAlternativeContainerdShim(t *testing.T) {
|
|||
t.Errorf("shimDir RemoveAll cleanup: %v", err)
|
||||
}
|
||||
})
|
||||
assert.Assert(t, os.Chmod(shimDir, 0777))
|
||||
assert.Assert(t, os.Chmod(shimDir, 0o777))
|
||||
shimDir, err = filepath.Abs(shimDir)
|
||||
assert.Assert(t, err)
|
||||
assert.Assert(t, os.Symlink(realShimPath, filepath.Join(shimDir, "containerd-shim-realfake-v42")))
|
||||
|
|
Loading…
Add table
Reference in a new issue