@@ -74,8 +74,7 @@ func TestWriteCertificateAuthorityFilesIfNotExist(t *testing.T) {
74
74
75
75
for _ , test := range tests {
76
76
// Create temp folder for the test case
77
- tmpdir := testutil .SetupTempDir (t )
78
- defer os .RemoveAll (tmpdir )
77
+ tmpdir := t .TempDir ()
79
78
80
79
// executes setup func (if necessary)
81
80
if test .setupFunc != nil {
@@ -179,8 +178,7 @@ func TestWriteCertificateFilesIfNotExist(t *testing.T) {
179
178
180
179
for _ , test := range tests {
181
180
// Create temp folder for the test case
182
- tmpdir := testutil .SetupTempDir (t )
183
- defer os .RemoveAll (tmpdir )
181
+ tmpdir := t .TempDir ()
184
182
185
183
// executes setup func (if necessary)
186
184
if test .setupFunc != nil {
@@ -252,8 +250,7 @@ func TestCreateServiceAccountKeyAndPublicKeyFiles(t *testing.T) {
252
250
}
253
251
for _ , tt := range tcases {
254
252
t .Run (tt .name , func (t * testing.T ) {
255
- dir := testutil .SetupTempDir (t )
256
- defer os .RemoveAll (dir )
253
+ dir := t .TempDir ()
257
254
258
255
if tt .setupFunc != nil {
259
256
if err := tt .setupFunc (dir ); err != nil {
@@ -383,9 +380,8 @@ func TestSharedCertificateExists(t *testing.T) {
383
380
384
381
for _ , test := range tests {
385
382
t .Run ("" , func (t * testing.T ) {
386
- tmpdir := testutil . SetupTempDir ( t )
383
+ tmpdir := t . TempDir ( )
387
384
os .MkdirAll (tmpdir + "/etcd" , os .ModePerm )
388
- defer os .RemoveAll (tmpdir )
389
385
390
386
cfg := & kubeadmapi.ClusterConfiguration {
391
387
CertificatesDir : tmpdir ,
@@ -415,8 +411,7 @@ func TestCreatePKIAssetsWithSparseCerts(t *testing.T) {
415
411
t .Run (test .Name , func (t * testing.T ) {
416
412
pkiutiltesting .Reset ()
417
413
418
- tmpdir := testutil .SetupTempDir (t )
419
- defer os .RemoveAll (tmpdir )
414
+ tmpdir := t .TempDir ()
420
415
421
416
cfg := testutil .GetDefaultInternalConfig (t )
422
417
cfg .ClusterConfiguration .CertificatesDir = tmpdir
@@ -518,8 +513,7 @@ func TestUsingExternalCA(t *testing.T) {
518
513
t .Run (test .name , func (t * testing.T ) {
519
514
pkiutiltesting .Reset ()
520
515
521
- dir := testutil .SetupTempDir (t )
522
- defer os .RemoveAll (dir )
516
+ dir := t .TempDir ()
523
517
524
518
cfg := & kubeadmapi.InitConfiguration {
525
519
LocalAPIEndpoint : kubeadmapi.APIEndpoint {AdvertiseAddress : "1.2.3.4" },
@@ -622,8 +616,7 @@ func TestValidateMethods(t *testing.T) {
622
616
}
623
617
624
618
for _ , test := range tests {
625
- dir := testutil .SetupTempDir (t )
626
- defer os .RemoveAll (dir )
619
+ dir := t .TempDir ()
627
620
test .loc .pkiDir = dir
628
621
629
622
certstestutil .WritePKIFiles (t , dir , test .files )
@@ -678,8 +671,7 @@ func TestCreateCertificateFilesMethods(t *testing.T) {
678
671
pkiutiltesting .Reset ()
679
672
680
673
// Create temp folder for the test case
681
- tmpdir := testutil .SetupTempDir (t )
682
- defer os .RemoveAll (tmpdir )
674
+ tmpdir := t .TempDir ()
683
675
684
676
cfg := & kubeadmapi.InitConfiguration {
685
677
LocalAPIEndpoint : kubeadmapi.APIEndpoint {AdvertiseAddress : "1.2.3.4" },
0 commit comments