@@ -2579,7 +2579,7 @@ func TestNotZero(t *testing.T) {
25792579}
25802580
25812581func TestFileExists (t * testing.T ) {
2582- // FIXME t.Parallel()
2582+ t .Parallel ()
25832583
25842584 mockT := new (testing.T )
25852585 True (t , FileExists (mockT , "assertions.go" ))
@@ -2590,32 +2590,17 @@ func TestFileExists(t *testing.T) {
25902590 mockT = new (testing.T )
25912591 False (t , FileExists (mockT , "../_codegen" ))
25922592
2593- var tempFiles []string
2594-
2595- link , err := getTempSymlinkPath ("assertions.go" )
2596- if err != nil {
2597- t .Fatal ("could not create temp symlink, err:" , err )
2598- }
2599- tempFiles = append (tempFiles , link )
2593+ link := getTempSymlinkPath (t , "assertions.go" )
26002594 mockT = new (testing.T )
26012595 True (t , FileExists (mockT , link ))
26022596
2603- link , err = getTempSymlinkPath ("non_existent_file" )
2604- if err != nil {
2605- t .Fatal ("could not create temp symlink, err:" , err )
2606- }
2607- tempFiles = append (tempFiles , link )
2597+ link = getTempSymlinkPath (t , "non_existent_file" )
26082598 mockT = new (testing.T )
26092599 True (t , FileExists (mockT , link ))
2610-
2611- errs := cleanUpTempFiles (tempFiles )
2612- if len (errs ) > 0 {
2613- t .Fatal ("could not clean up temporary files" )
2614- }
26152600}
26162601
26172602func TestNoFileExists (t * testing.T ) {
2618- // FIXME t.Parallel()
2603+ t .Parallel ()
26192604
26202605 mockT := new (testing.T )
26212606 False (t , NoFileExists (mockT , "assertions.go" ))
@@ -2626,49 +2611,28 @@ func TestNoFileExists(t *testing.T) {
26262611 mockT = new (testing.T )
26272612 True (t , NoFileExists (mockT , "../_codegen" ))
26282613
2629- var tempFiles []string
2630-
2631- link , err := getTempSymlinkPath ("assertions.go" )
2632- if err != nil {
2633- t .Fatal ("could not create temp symlink, err:" , err )
2634- }
2635- tempFiles = append (tempFiles , link )
2614+ link := getTempSymlinkPath (t , "assertions.go" )
26362615 mockT = new (testing.T )
26372616 False (t , NoFileExists (mockT , link ))
26382617
2639- link , err = getTempSymlinkPath ("non_existent_file" )
2640- if err != nil {
2641- t .Fatal ("could not create temp symlink, err:" , err )
2642- }
2643- tempFiles = append (tempFiles , link )
2618+ link = getTempSymlinkPath (t , "non_existent_file" )
26442619 mockT = new (testing.T )
26452620 False (t , NoFileExists (mockT , link ))
2646-
2647- errs := cleanUpTempFiles (tempFiles )
2648- if len (errs ) > 0 {
2649- t .Fatal ("could not clean up temporary files" )
2650- }
26512621}
26522622
2653- func getTempSymlinkPath (file string ) (string , error ) {
2654- link := file + "_symlink"
2655- err := os .Symlink (file , link )
2656- return link , err
2657- }
2623+ func getTempSymlinkPath (t * testing.T , file string ) string {
2624+ t .Helper ()
26582625
2659- func cleanUpTempFiles (paths []string ) []error {
2660- var res []error
2661- for _ , path := range paths {
2662- err := os .Remove (path )
2663- if err != nil {
2664- res = append (res , err )
2665- }
2626+ tempDir := t .TempDir ()
2627+ link := filepath .Join (tempDir , file + "_symlink" )
2628+ if err := os .Symlink (file , link ); err != nil {
2629+ t .Fatalf ("could not create temp symlink %q pointing to %q: %v" , link , file , err )
26662630 }
2667- return res
2631+ return link
26682632}
26692633
26702634func TestDirExists (t * testing.T ) {
2671- // FIXME t.Parallel()
2635+ t .Parallel ()
26722636
26732637 mockT := new (testing.T )
26742638 False (t , DirExists (mockT , "assertions.go" ))
@@ -2679,32 +2643,17 @@ func TestDirExists(t *testing.T) {
26792643 mockT = new (testing.T )
26802644 True (t , DirExists (mockT , "../_codegen" ))
26812645
2682- var tempFiles []string
2683-
2684- link , err := getTempSymlinkPath ("assertions.go" )
2685- if err != nil {
2686- t .Fatal ("could not create temp symlink, err:" , err )
2687- }
2688- tempFiles = append (tempFiles , link )
2646+ link := getTempSymlinkPath (t , "assertions.go" )
26892647 mockT = new (testing.T )
26902648 False (t , DirExists (mockT , link ))
26912649
2692- link , err = getTempSymlinkPath ("non_existent_dir" )
2693- if err != nil {
2694- t .Fatal ("could not create temp symlink, err:" , err )
2695- }
2696- tempFiles = append (tempFiles , link )
2650+ link = getTempSymlinkPath (t , "non_existent_dir" )
26972651 mockT = new (testing.T )
26982652 False (t , DirExists (mockT , link ))
2699-
2700- errs := cleanUpTempFiles (tempFiles )
2701- if len (errs ) > 0 {
2702- t .Fatal ("could not clean up temporary files" )
2703- }
27042653}
27052654
27062655func TestNoDirExists (t * testing.T ) {
2707- // FIXME t.Parallel()
2656+ t .Parallel ()
27082657
27092658 mockT := new (testing.T )
27102659 True (t , NoDirExists (mockT , "assertions.go" ))
@@ -2715,28 +2664,13 @@ func TestNoDirExists(t *testing.T) {
27152664 mockT = new (testing.T )
27162665 False (t , NoDirExists (mockT , "../_codegen" ))
27172666
2718- var tempFiles []string
2719-
2720- link , err := getTempSymlinkPath ("assertions.go" )
2721- if err != nil {
2722- t .Fatal ("could not create temp symlink, err:" , err )
2723- }
2724- tempFiles = append (tempFiles , link )
2667+ link := getTempSymlinkPath (t , "assertions.go" )
27252668 mockT = new (testing.T )
27262669 True (t , NoDirExists (mockT , link ))
27272670
2728- link , err = getTempSymlinkPath ("non_existent_dir" )
2729- if err != nil {
2730- t .Fatal ("could not create temp symlink, err:" , err )
2731- }
2732- tempFiles = append (tempFiles , link )
2671+ link = getTempSymlinkPath (t , "non_existent_dir" )
27332672 mockT = new (testing.T )
27342673 True (t , NoDirExists (mockT , link ))
2735-
2736- errs := cleanUpTempFiles (tempFiles )
2737- if len (errs ) > 0 {
2738- t .Fatal ("could not clean up temporary files" )
2739- }
27402674}
27412675
27422676func TestJSONEq_EqualSONString (t * testing.T ) {
0 commit comments