mirror of https://github.com/docker/cli.git
cli/command/image/build/context_test.go:244:38: `createTestTempDir` - `dir` always receives `""` (unparam)
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
parent
e1c0c7979e
commit
70bd64d037
|
@ -24,11 +24,11 @@ var prepareEmpty = func(t *testing.T) (string, func()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var prepareNoFiles = 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()) {
|
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)
|
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
||||||
return contextDir, cleanup
|
return contextDir, cleanup
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func testValidateContextDirectory(t *testing.T, prepare func(t *testing.T) (stri
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContextFromLocalDirNoDockerfile(t *testing.T) {
|
func TestGetContextFromLocalDirNoDockerfile(t *testing.T) {
|
||||||
contextDir, cleanup := createTestTempDir(t, "", "builder-context-test")
|
contextDir, cleanup := createTestTempDir(t, "builder-context-test")
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
_, _, err := GetContextFromLocalDir(contextDir, "")
|
_, _, err := GetContextFromLocalDir(contextDir, "")
|
||||||
|
@ -50,7 +50,7 @@ func TestGetContextFromLocalDirNoDockerfile(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContextFromLocalDirNotExistingDir(t *testing.T) {
|
func TestGetContextFromLocalDirNotExistingDir(t *testing.T) {
|
||||||
contextDir, cleanup := createTestTempDir(t, "", "builder-context-test")
|
contextDir, cleanup := createTestTempDir(t, "builder-context-test")
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
fakePath := filepath.Join(contextDir, "fake")
|
fakePath := filepath.Join(contextDir, "fake")
|
||||||
|
@ -60,7 +60,7 @@ func TestGetContextFromLocalDirNotExistingDir(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContextFromLocalDirNotExistingDockerfile(t *testing.T) {
|
func TestGetContextFromLocalDirNotExistingDockerfile(t *testing.T) {
|
||||||
contextDir, cleanup := createTestTempDir(t, "", "builder-context-test")
|
contextDir, cleanup := createTestTempDir(t, "builder-context-test")
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
fakePath := filepath.Join(contextDir, "fake")
|
fakePath := filepath.Join(contextDir, "fake")
|
||||||
|
@ -70,7 +70,7 @@ func TestGetContextFromLocalDirNotExistingDockerfile(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContextFromLocalDirWithNoDirectory(t *testing.T) {
|
func TestGetContextFromLocalDirWithNoDirectory(t *testing.T) {
|
||||||
contextDir, dirCleanup := createTestTempDir(t, "", "builder-context-test")
|
contextDir, dirCleanup := createTestTempDir(t, "builder-context-test")
|
||||||
defer dirCleanup()
|
defer dirCleanup()
|
||||||
|
|
||||||
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
||||||
|
@ -86,7 +86,7 @@ func TestGetContextFromLocalDirWithNoDirectory(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContextFromLocalDirWithDockerfile(t *testing.T) {
|
func TestGetContextFromLocalDirWithDockerfile(t *testing.T) {
|
||||||
contextDir, cleanup := createTestTempDir(t, "", "builder-context-test")
|
contextDir, cleanup := createTestTempDir(t, "builder-context-test")
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
||||||
|
@ -99,7 +99,7 @@ func TestGetContextFromLocalDirWithDockerfile(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContextFromLocalDirLocalFile(t *testing.T) {
|
func TestGetContextFromLocalDirLocalFile(t *testing.T) {
|
||||||
contextDir, cleanup := createTestTempDir(t, "", "builder-context-test")
|
contextDir, cleanup := createTestTempDir(t, "builder-context-test")
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
||||||
|
@ -121,7 +121,7 @@ func TestGetContextFromLocalDirLocalFile(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContextFromLocalDirWithCustomDockerfile(t *testing.T) {
|
func TestGetContextFromLocalDirWithCustomDockerfile(t *testing.T) {
|
||||||
contextDir, cleanup := createTestTempDir(t, "", "builder-context-test")
|
contextDir, cleanup := createTestTempDir(t, "builder-context-test")
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
chdirCleanup := chdir(t, contextDir)
|
chdirCleanup := chdir(t, contextDir)
|
||||||
|
@ -173,7 +173,7 @@ func TestGetContextFromReaderString(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContextFromReaderTar(t *testing.T) {
|
func TestGetContextFromReaderTar(t *testing.T) {
|
||||||
contextDir, cleanup := createTestTempDir(t, "", "builder-context-test")
|
contextDir, cleanup := createTestTempDir(t, "builder-context-test")
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777)
|
||||||
|
@ -241,8 +241,8 @@ func TestValidateContextDirectoryWithOneFileExcludes(t *testing.T) {
|
||||||
// createTestTempDir creates a temporary directory for testing.
|
// 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.
|
// 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.
|
// When an error occurs, it terminates the test.
|
||||||
func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) {
|
func createTestTempDir(t *testing.T, prefix string) (string, func()) {
|
||||||
path, err := ioutil.TempDir(dir, prefix)
|
path, err := ioutil.TempDir("", prefix)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
return path, func() { assert.NilError(t, os.RemoveAll(path)) }
|
return path, func() { assert.NilError(t, os.RemoveAll(path)) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue