@@ -2823,6 +2823,53 @@ func TestDoubleCloseError(t *testing.T) {
2823
2823
t .Run ("dir" , testDoubleCloseError (sfdir ))
2824
2824
}
2825
2825
2826
+ func TestUserCacheDir (t * testing.T ) {
2827
+ t .Parallel ()
2828
+
2829
+ dir , err := UserCacheDir ()
2830
+ if err != nil {
2831
+ t .Skipf ("skipping: %v" , err )
2832
+ }
2833
+ if dir == "" {
2834
+ t .Fatalf ("UserCacheDir returned %q; want non-empty path or error" , dir )
2835
+ }
2836
+
2837
+ if err := MkdirAll (dir , 0777 ); err != nil {
2838
+ t .Fatalf ("could not create UserCacheDir: %v" , err )
2839
+ }
2840
+ d , err := MkdirTemp (dir , "TestUserCacheDir" )
2841
+ if err != nil {
2842
+ t .Fatalf ("could not create a directory in UserCacheDir: %v" , err )
2843
+ }
2844
+ if err := Remove (d ); err != nil {
2845
+ t .Fatal (err )
2846
+ }
2847
+ }
2848
+
2849
+ func TestUserConfigDir (t * testing.T ) {
2850
+ t .Parallel ()
2851
+
2852
+ dir , err := UserConfigDir ()
2853
+ if err != nil {
2854
+ t .Skipf ("skipping: %v" , err )
2855
+ }
2856
+ if dir == "" {
2857
+ t .Fatalf ("UserConfigDir returned %q; want non-empty path or error" , dir )
2858
+ }
2859
+
2860
+ if err := MkdirAll (dir , 0777 ); err != nil {
2861
+ t .Fatalf ("could not create UserConfigDir: %v" , err )
2862
+ }
2863
+
2864
+ d , err := MkdirTemp (dir , "TestUserConfigDir" )
2865
+ if err != nil {
2866
+ t .Fatalf ("could not create a directory in UserConfigDir: %v" , err )
2867
+ }
2868
+ if err := Remove (d ); err != nil {
2869
+ t .Fatal (err )
2870
+ }
2871
+ }
2872
+
2826
2873
func TestUserHomeDir (t * testing.T ) {
2827
2874
t .Parallel ()
2828
2875
0 commit comments