mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
integration-cli: remove createTmpFile utility
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -2941,10 +2941,11 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMount(c *testing.T) {
|
||||
// Not applicable on Windows as uses Unix specific functionality
|
||||
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
|
||||
|
||||
expected := "test123"
|
||||
tmpDir := c.TempDir()
|
||||
filename := filepath.Join(tmpDir, "testfile")
|
||||
|
||||
filename := createTmpFile(c, expected)
|
||||
defer os.Remove(filename)
|
||||
const expected = "test123"
|
||||
assert.NilError(c, os.WriteFile(filename, []byte(expected), 0o644))
|
||||
|
||||
// #nosec G302 -- for user namespaced test runs, the temp file must be accessible to unprivileged root
|
||||
if err := os.Chmod(filename, 0o646); err != nil {
|
||||
@@ -2965,8 +2966,9 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMountRO(c *testing.T) {
|
||||
// Not applicable on Windows as uses Unix specific functionality
|
||||
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
|
||||
|
||||
filename := createTmpFile(c, "test123")
|
||||
defer os.Remove(filename)
|
||||
tmpDir := c.TempDir()
|
||||
filename := filepath.Join(tmpDir, "testfile")
|
||||
assert.NilError(c, os.WriteFile(filename, []byte("test123"), 0o644))
|
||||
|
||||
// #nosec G302 -- for user namespaced test runs, the temp file must be accessible to unprivileged root
|
||||
if err := os.Chmod(filename, 0o646); err != nil {
|
||||
@@ -2987,8 +2989,9 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMountROFilesystem(c *testing.
|
||||
// Not applicable on Windows as uses Unix specific functionality
|
||||
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, UserNamespaceROMount)
|
||||
|
||||
filename := createTmpFile(c, "test123")
|
||||
defer os.Remove(filename)
|
||||
tmpDir := c.TempDir()
|
||||
filename := filepath.Join(tmpDir, "testfile")
|
||||
assert.NilError(c, os.WriteFile(filename, []byte("test123"), 0o644))
|
||||
|
||||
// #nosec G302 -- for user namespaced test runs, the temp file must be accessible to unprivileged root
|
||||
if err := os.Chmod(filename, 0o646); err != nil {
|
||||
|
||||
@@ -271,19 +271,6 @@ func appendBaseEnv(isTLS bool, env ...string) []string {
|
||||
return env
|
||||
}
|
||||
|
||||
func createTmpFile(t *testing.T, content string) string {
|
||||
t.Helper()
|
||||
f, err := os.CreateTemp("", "testfile")
|
||||
assert.NilError(t, err)
|
||||
|
||||
filename := f.Name()
|
||||
|
||||
err = os.WriteFile(filename, []byte(content), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
return filename
|
||||
}
|
||||
|
||||
// waitInspect will wait for the specified container to have the specified string
|
||||
// in the inspect output. It will wait until the specified timeout (in seconds)
|
||||
// is reached.
|
||||
|
||||
Reference in New Issue
Block a user