11package dependency
22
33import (
4- "github.com/loft-sh/devspace/pkg/devspace/dependency/types"
5- "io/ioutil"
64 "os"
75 "path/filepath"
86 "testing"
97
8+ "github.com/loft-sh/devspace/pkg/devspace/dependency/types"
9+
1010 "github.com/loft-sh/devspace/pkg/devspace/build"
1111 fakebuild "github.com/loft-sh/devspace/pkg/devspace/build/testing"
1212 "github.com/loft-sh/devspace/pkg/devspace/config"
@@ -89,10 +89,7 @@ func TestUpdateAll(t *testing.T) {
8989 },
9090 }
9191
92- dir , err := ioutil .TempDir ("" , "testFolder" )
93- if err != nil {
94- t .Fatalf ("Error creating temporary directory: %v" , err )
95- }
92+ dir := t .TempDir ()
9693
9794 wdBackup , err := os .Getwd ()
9895 if err != nil {
@@ -109,10 +106,6 @@ func TestUpdateAll(t *testing.T) {
109106 if err != nil {
110107 t .Fatalf ("Error changing dir back: %v" , err )
111108 }
112- err = os .RemoveAll (dir )
113- if err != nil {
114- t .Fatalf ("Error removing dir: %v" , err )
115- }
116109 }()
117110
118111 for _ , testCase := range testCases {
@@ -163,10 +156,7 @@ type buildAllTestCase struct {
163156}
164157
165158func TestBuildAll (t * testing.T ) {
166- dir , err := ioutil .TempDir ("" , "testFolder" )
167- if err != nil {
168- t .Fatalf ("Error creating temporary directory: %v" , err )
169- }
159+ dir := t .TempDir ()
170160
171161 wdBackup , err := os .Getwd ()
172162 if err != nil {
@@ -187,10 +177,6 @@ func TestBuildAll(t *testing.T) {
187177 if err != nil {
188178 t .Fatalf ("Error changing dir back: %v" , err )
189179 }
190- err = os .RemoveAll (dir )
191- if err != nil {
192- t .Fatalf ("Error removing dir: %v" , err )
193- }
194180 }()
195181
196182 testCases := []buildAllTestCase {
@@ -264,10 +250,7 @@ type deployAllTestCase struct {
264250}
265251
266252func TestDeployAll (t * testing.T ) {
267- dir , err := ioutil .TempDir ("" , "testFolder" )
268- if err != nil {
269- t .Fatalf ("Error creating temporary directory: %v" , err )
270- }
253+ dir := t .TempDir ()
271254
272255 wdBackup , err := os .Getwd ()
273256 if err != nil {
@@ -288,10 +271,6 @@ func TestDeployAll(t *testing.T) {
288271 if err != nil {
289272 t .Fatalf ("Error changing dir back: %v" , err )
290273 }
291- err = os .RemoveAll (dir )
292- if err != nil {
293- t .Fatalf ("Error removing dir: %v" , err )
294- }
295274 }()
296275
297276 testCases := []deployAllTestCase {
@@ -365,11 +344,7 @@ type purgeAllTestCase struct {
365344}
366345
367346func TestPurgeAll (t * testing.T ) {
368- dir , err := ioutil .TempDir ("" , "testFolder" )
369- if err != nil {
370- t .Fatalf ("Error creating temporary directory: %v" , err )
371- }
372- dir , err = filepath .EvalSymlinks (dir )
347+ dir , err := filepath .EvalSymlinks (t .TempDir ())
373348 if err != nil {
374349 t .Fatal (err )
375350 }
@@ -389,10 +364,6 @@ func TestPurgeAll(t *testing.T) {
389364 if err != nil {
390365 t .Fatalf ("Error changing dir back: %v" , err )
391366 }
392- err = os .RemoveAll (dir )
393- if err != nil {
394- t .Fatalf ("Error removing dir: %v" , err )
395- }
396367 }()
397368
398369 testCases := []purgeAllTestCase {
@@ -470,11 +441,7 @@ type buildTestCase struct {
470441}
471442
472443func TestBuild (t * testing.T ) {
473- dir , err := ioutil .TempDir ("" , "testFolder" )
474- if err != nil {
475- t .Fatalf ("Error creating temporary directory: %v" , err )
476- }
477- dir , err = filepath .EvalSymlinks (dir )
444+ dir , err := filepath .EvalSymlinks (t .TempDir ())
478445 if err != nil {
479446 t .Fatal (err )
480447 }
@@ -494,10 +461,6 @@ func TestBuild(t *testing.T) {
494461 if err != nil {
495462 t .Fatalf ("Error changing dir back: %v" , err )
496463 }
497- err = os .RemoveAll (dir )
498- if err != nil {
499- t .Fatalf ("Error removing dir: %v" , err )
500- }
501464 }()
502465
503466 testCases := []buildTestCase {
@@ -591,11 +554,7 @@ type deployTestCase struct {
591554}
592555
593556func TestDeploy (t * testing.T ) {
594- dir , err := ioutil .TempDir ("" , "testFolder" )
595- if err != nil {
596- t .Fatalf ("Error creating temporary directory: %v" , err )
597- }
598- dir , err = filepath .EvalSymlinks (dir )
557+ dir , err := filepath .EvalSymlinks (t .TempDir ())
599558 if err != nil {
600559 t .Fatal (err )
601560 }
@@ -615,10 +574,6 @@ func TestDeploy(t *testing.T) {
615574 if err != nil {
616575 t .Fatalf ("Error changing dir back: %v" , err )
617576 }
618- err = os .RemoveAll (dir )
619- if err != nil {
620- t .Fatalf ("Error removing dir: %v" , err )
621- }
622577 }()
623578
624579 testCases := []deployTestCase {
0 commit comments