Skip to content

Commit

Permalink
cli/command/image/build/context_test.go:244:38: createTestTempDir -…
Browse files Browse the repository at this point in the history
… `dir` always receives `""` (unparam)

Signed-off-by: Silvin Lubecki <[email protected]>
  • Loading branch information
silvin-lubecki authored and thaJeztah committed Oct 31, 2019
1 parent e1c0c79 commit 70bd64d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions cli/command/image/build/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -42,15 +42,15 @@ 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, "")
assert.ErrorContains(t, err, "Dockerfile")
}

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")
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)) }
}
Expand Down

0 comments on commit 70bd64d

Please sign in to comment.