@@ -2579,7 +2579,7 @@ func TestNotZero(t *testing.T) {
2579
2579
}
2580
2580
2581
2581
func TestFileExists (t * testing.T ) {
2582
- // FIXME t.Parallel()
2582
+ t .Parallel ()
2583
2583
2584
2584
mockT := new (testing.T )
2585
2585
True (t , FileExists (mockT , "assertions.go" ))
@@ -2590,32 +2590,17 @@ func TestFileExists(t *testing.T) {
2590
2590
mockT = new (testing.T )
2591
2591
False (t , FileExists (mockT , "../_codegen" ))
2592
2592
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" )
2600
2594
mockT = new (testing.T )
2601
2595
True (t , FileExists (mockT , link ))
2602
2596
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" )
2608
2598
mockT = new (testing.T )
2609
2599
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
- }
2615
2600
}
2616
2601
2617
2602
func TestNoFileExists (t * testing.T ) {
2618
- // FIXME t.Parallel()
2603
+ t .Parallel ()
2619
2604
2620
2605
mockT := new (testing.T )
2621
2606
False (t , NoFileExists (mockT , "assertions.go" ))
@@ -2626,49 +2611,28 @@ func TestNoFileExists(t *testing.T) {
2626
2611
mockT = new (testing.T )
2627
2612
True (t , NoFileExists (mockT , "../_codegen" ))
2628
2613
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" )
2636
2615
mockT = new (testing.T )
2637
2616
False (t , NoFileExists (mockT , link ))
2638
2617
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" )
2644
2619
mockT = new (testing.T )
2645
2620
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
- }
2651
2621
}
2652
2622
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 ()
2658
2625
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 )
2666
2630
}
2667
- return res
2631
+ return link
2668
2632
}
2669
2633
2670
2634
func TestDirExists (t * testing.T ) {
2671
- // FIXME t.Parallel()
2635
+ t .Parallel ()
2672
2636
2673
2637
mockT := new (testing.T )
2674
2638
False (t , DirExists (mockT , "assertions.go" ))
@@ -2679,32 +2643,17 @@ func TestDirExists(t *testing.T) {
2679
2643
mockT = new (testing.T )
2680
2644
True (t , DirExists (mockT , "../_codegen" ))
2681
2645
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" )
2689
2647
mockT = new (testing.T )
2690
2648
False (t , DirExists (mockT , link ))
2691
2649
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" )
2697
2651
mockT = new (testing.T )
2698
2652
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
- }
2704
2653
}
2705
2654
2706
2655
func TestNoDirExists (t * testing.T ) {
2707
- // FIXME t.Parallel()
2656
+ t .Parallel ()
2708
2657
2709
2658
mockT := new (testing.T )
2710
2659
True (t , NoDirExists (mockT , "assertions.go" ))
@@ -2715,28 +2664,13 @@ func TestNoDirExists(t *testing.T) {
2715
2664
mockT = new (testing.T )
2716
2665
False (t , NoDirExists (mockT , "../_codegen" ))
2717
2666
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" )
2725
2668
mockT = new (testing.T )
2726
2669
True (t , NoDirExists (mockT , link ))
2727
2670
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" )
2733
2672
mockT = new (testing.T )
2734
2673
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
- }
2740
2674
}
2741
2675
2742
2676
func TestJSONEq_EqualSONString (t * testing.T ) {
0 commit comments