Skip to content

Commit 860bceb

Browse files
committed
fix style
1 parent e9aa6e8 commit 860bceb

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

pkg/skaffold/initializer/init_test.go

+20-22
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package initializer
1818

1919
import (
2020
"bytes"
21-
"os"
2221
"strings"
2322
"testing"
2423

@@ -27,36 +26,36 @@ import (
2726

2827
func TestPrintAnalyzeJSON(t *testing.T) {
2928
tests := []struct {
30-
name string
29+
description string
3130
dockerfiles []string
3231
images []string
3332
skipBuild bool
3433
shouldErr bool
3534
expected string
3635
}{
3736
{
38-
name: "dockerfile and image",
37+
description: "dockerfile and image",
3938
dockerfiles: []string{"Dockerfile", "Dockerfile_2"},
4039
images: []string{"image1", "image2"},
4140
expected: "{\"dockerfiles\":[\"Dockerfile\",\"Dockerfile_2\"],\"images\":[\"image1\",\"image2\"]}",
4241
},
4342
{
44-
name: "no dockerfile, skip build",
45-
images: []string{"image1", "image2"},
46-
skipBuild: true,
47-
expected: "{\"images\":[\"image1\",\"image2\"]}"},
43+
description: "no dockerfile, skip build",
44+
images: []string{"image1", "image2"},
45+
skipBuild: true,
46+
expected: "{\"images\":[\"image1\",\"image2\"]}"},
4847
{
49-
name: "no dockerfile",
50-
images: []string{"image1", "image2"},
51-
shouldErr: true,
48+
description: "no dockerfile",
49+
images: []string{"image1", "image2"},
50+
shouldErr: true,
5251
},
5352
{
54-
name: "no dockerfiles or images",
55-
shouldErr: true,
53+
description: "no dockerfiles or images",
54+
shouldErr: true,
5655
},
5756
}
5857
for _, test := range tests {
59-
t.Run(test.name, func(t *testing.T) {
58+
t.Run(test.description, func(t *testing.T) {
6059
out := bytes.NewBuffer([]byte{})
6160
err := printAnalyzeJSON(out, test.skipBuild, test.dockerfiles, test.images)
6261
testutil.CheckErrorAndDeepEqual(t, test.shouldErr, err, test.expected, out.String())
@@ -67,15 +66,15 @@ func TestPrintAnalyzeJSON(t *testing.T) {
6766
func TestWalk(t *testing.T) {
6867
emptyFile := ""
6968
tests := []struct {
70-
name string
69+
description string
7170
filesWithContents map[string]string
7271
expectedConfigs []string
7372
expectedDockerfiles []string
7473
force bool
7574
shouldErr bool
7675
}{
7776
{
78-
name: "should return correct k8 configs and dockerfiles",
77+
description: "should return correct k8 configs and dockerfiles",
7978
filesWithContents: map[string]string{
8079
"config/test.yaml": emptyFile,
8180
"k8pod.yml": emptyFile,
@@ -95,7 +94,7 @@ func TestWalk(t *testing.T) {
9594
shouldErr: false,
9695
},
9796
{
98-
name: "should skip hidden dir",
97+
description: "should skip hidden dir",
9998
filesWithContents: map[string]string{
10099
".hidden/test.yaml": emptyFile,
101100
"k8pod.yml": emptyFile,
@@ -113,7 +112,7 @@ func TestWalk(t *testing.T) {
113112
shouldErr: false,
114113
},
115114
{
116-
name: "should not error when skaffold.config present and force = true",
115+
description: "should not error when skaffold.config present and force = true",
117116
filesWithContents: map[string]string{
118117
"skaffold.yaml": `apiVersion: skaffold/v1beta6
119118
kind: Config
@@ -137,7 +136,7 @@ deploy:
137136
shouldErr: false,
138137
},
139138
{
140-
name: "should error when skaffold.config present and force = false",
139+
description: "should error when skaffold.config present and force = false",
141140
filesWithContents: map[string]string{
142141
"config/test.yaml": emptyFile,
143142
"k8pod.yml": emptyFile,
@@ -156,17 +155,16 @@ deploy:
156155
},
157156
}
158157
for _, test := range tests {
159-
t.Run(test.name, func(t *testing.T) {
160-
testDir, deleteFunc := testutil.NewTempDir(t)
158+
t.Run(test.description, func(t *testing.T) {
159+
testDir, cleanUp := testutil.NewTempDir(t)
160+
defer cleanUp()
161161
rootDir := testDir.Root()
162-
deleteFunc()
163162
writeAllFiles(testDir, test.filesWithContents)
164163
potentialConfigs, dockerfiles, err := walk(rootDir, test.force, testValidDocker)
165164
testutil.CheckErrorAndDeepEqual(t, test.shouldErr, err,
166165
testDir.Paths(test.expectedConfigs), potentialConfigs)
167166
testutil.CheckErrorAndDeepEqual(t, test.shouldErr, err,
168167
testDir.Paths(test.expectedDockerfiles), dockerfiles)
169-
os.Remove(rootDir)
170168
})
171169
}
172170
}

0 commit comments

Comments
 (0)