diff --git a/cli/command/image/build/context_test.go b/cli/command/image/build/context_test.go index de4d38f75d..5404f7aa5d 100644 --- a/cli/command/image/build/context_test.go +++ b/cli/command/image/build/context_test.go @@ -24,11 +24,11 @@ var prepareEmpty = func(t *testing.T) (string, func()) { } var prepareNoFiles = func(t *testing.T) (string, func()) { - return createTestTempDir(t, "", "builder-context-test") + return createTestTempDir(t, "builder-context-test") } var prepareOneFile = func(t *testing.T) (string, func()) { - contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, cleanup := createTestTempDir(t, "builder-context-test") createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) return contextDir, cleanup } @@ -42,7 +42,7 @@ func testValidateContextDirectory(t *testing.T, prepare func(t *testing.T) (stri } func TestGetContextFromLocalDirNoDockerfile(t *testing.T) { - contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, cleanup := createTestTempDir(t, "builder-context-test") defer cleanup() _, _, err := GetContextFromLocalDir(contextDir, "") @@ -50,7 +50,7 @@ func TestGetContextFromLocalDirNoDockerfile(t *testing.T) { } func TestGetContextFromLocalDirNotExistingDir(t *testing.T) { - contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, cleanup := createTestTempDir(t, "builder-context-test") defer cleanup() fakePath := filepath.Join(contextDir, "fake") @@ -60,7 +60,7 @@ func TestGetContextFromLocalDirNotExistingDir(t *testing.T) { } func TestGetContextFromLocalDirNotExistingDockerfile(t *testing.T) { - contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, cleanup := createTestTempDir(t, "builder-context-test") defer cleanup() fakePath := filepath.Join(contextDir, "fake") @@ -70,7 +70,7 @@ func TestGetContextFromLocalDirNotExistingDockerfile(t *testing.T) { } func TestGetContextFromLocalDirWithNoDirectory(t *testing.T) { - contextDir, dirCleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, dirCleanup := createTestTempDir(t, "builder-context-test") defer dirCleanup() createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) @@ -86,7 +86,7 @@ func TestGetContextFromLocalDirWithNoDirectory(t *testing.T) { } func TestGetContextFromLocalDirWithDockerfile(t *testing.T) { - contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, cleanup := createTestTempDir(t, "builder-context-test") defer cleanup() createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) @@ -99,7 +99,7 @@ func TestGetContextFromLocalDirWithDockerfile(t *testing.T) { } func TestGetContextFromLocalDirLocalFile(t *testing.T) { - contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, cleanup := createTestTempDir(t, "builder-context-test") defer cleanup() createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) @@ -121,7 +121,7 @@ func TestGetContextFromLocalDirLocalFile(t *testing.T) { } func TestGetContextFromLocalDirWithCustomDockerfile(t *testing.T) { - contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, cleanup := createTestTempDir(t, "builder-context-test") defer cleanup() chdirCleanup := chdir(t, contextDir) @@ -173,7 +173,7 @@ func TestGetContextFromReaderString(t *testing.T) { } func TestGetContextFromReaderTar(t *testing.T) { - contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") + contextDir, cleanup := createTestTempDir(t, "builder-context-test") defer cleanup() createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) @@ -241,8 +241,8 @@ func TestValidateContextDirectoryWithOneFileExcludes(t *testing.T) { // createTestTempDir creates a temporary directory for testing. // It returns the created path and a cleanup function which is meant to be used as deferred call. // When an error occurs, it terminates the test. -func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) { - path, err := ioutil.TempDir(dir, prefix) +func createTestTempDir(t *testing.T, prefix string) (string, func()) { + path, err := ioutil.TempDir("", prefix) assert.NilError(t, err) return path, func() { assert.NilError(t, os.RemoveAll(path)) } }