@@ -4,17 +4,19 @@ import (
4
4
"os"
5
5
"testing"
6
6
7
+ "github.com/mitchellh/go-homedir"
7
8
"github.com/spf13/afero"
8
9
)
9
10
10
11
func TestMain (m * testing.M ) {
11
12
os .Unsetenv ("HOME" )
12
13
os .Unsetenv ("XDG_CONFIG_HOME" )
13
14
AppFs = afero .NewMemMapFs ()
15
+ homedir .DisableCache = true
14
16
os .Exit (m .Run ())
15
17
}
16
18
17
- func TestXDGConfigDirIsPrefferedFirst (t * testing.T ) {
19
+ func TestXDGConfigDirIsPreferredFirst (t * testing.T ) {
18
20
t .Cleanup (func () {
19
21
// reset fs after test
20
22
AppFs = afero .NewMemMapFs ()
@@ -40,6 +42,7 @@ func TestXDGConfigDirIsPrefferedFirst(t *testing.T) {
40
42
}
41
43
42
44
func TestHomeConfigDir (t * testing.T ) {
45
+ t .Cleanup (func () { AppFs = afero .NewMemMapFs () })
43
46
homeDirPath := "/tmp-iofs/home/tester"
44
47
AppFs .MkdirAll (homeDirPath , 0755 )
45
48
@@ -55,6 +58,7 @@ func TestHomeConfigDir(t *testing.T) {
55
58
}
56
59
57
60
func TestXDGConfigDir (t * testing.T ) {
61
+ t .Cleanup (func () { AppFs = afero .NewMemMapFs () })
58
62
xdgDirPath := "/tmp-iofs/xdg/config"
59
63
AppFs .MkdirAll (xdgDirPath , 0755 )
60
64
@@ -70,11 +74,12 @@ func TestXDGConfigDir(t *testing.T) {
70
74
}
71
75
72
76
func TestXDGConfigDirNoFile (t * testing.T ) {
77
+ t .Cleanup (func () { AppFs = afero .NewMemMapFs () })
73
78
xdgDirPath := "/tmp-iofs/xdg/config"
74
79
t .Setenv ("XDG_CONFIG_HOME" , xdgDirPath )
75
80
76
81
got := buildDefaultConfigPath ()
77
- want := xdgDirPath + "/revive.toml "
82
+ want := " "
78
83
79
84
if got != want {
80
85
t .Errorf ("got %q, wanted %q" , got , want )
0 commit comments