@@ -2,6 +2,7 @@ package cli
2
2
3
3
import (
4
4
"os"
5
+ "path/filepath"
5
6
"testing"
6
7
7
8
"github.com/mitchellh/go-homedir"
@@ -22,19 +23,19 @@ func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
22
23
AppFs = afero .NewMemMapFs ()
23
24
})
24
25
25
- xdgDirPath := "/tmp-iofs/xdg/config"
26
- homeDirPath := "/tmp-iofs/home/tester"
26
+ xdgDirPath := filepath . FromSlash ( "/tmp-iofs/xdg/config" )
27
+ homeDirPath := filepath . FromSlash ( "/tmp-iofs/home/tester" )
27
28
AppFs .MkdirAll (xdgDirPath , 0755 )
28
29
AppFs .MkdirAll (homeDirPath , 0755 )
29
30
30
- afero .WriteFile (AppFs , xdgDirPath + "/ revive.toml" , []byte ("\n " ), 0644 )
31
+ afero .WriteFile (AppFs , filepath . Join ( xdgDirPath , " revive.toml") , []byte ("\n " ), 0644 )
31
32
t .Setenv ("XDG_CONFIG_HOME" , xdgDirPath )
32
33
33
- afero .WriteFile (AppFs , homeDirPath + "/ revive.toml" , []byte ("\n " ), 0644 )
34
+ afero .WriteFile (AppFs , filepath . Join ( homeDirPath , " revive.toml") , []byte ("\n " ), 0644 )
34
35
t .Setenv ("HOME" , homeDirPath )
35
36
36
37
got := buildDefaultConfigPath ()
37
- want := xdgDirPath + "/ revive.toml"
38
+ want := filepath . Join ( xdgDirPath , " revive.toml")
38
39
39
40
if got != want {
40
41
t .Errorf ("got %q, wanted %q" , got , want )
@@ -43,14 +44,14 @@ func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
43
44
44
45
func TestHomeConfigDir (t * testing.T ) {
45
46
t .Cleanup (func () { AppFs = afero .NewMemMapFs () })
46
- homeDirPath := "/tmp-iofs/home/tester"
47
+ homeDirPath := filepath . FromSlash ( "/tmp-iofs/home/tester" )
47
48
AppFs .MkdirAll (homeDirPath , 0755 )
48
49
49
- afero .WriteFile (AppFs , homeDirPath + "/ revive.toml" , []byte ("\n " ), 0644 )
50
+ afero .WriteFile (AppFs , filepath . Join ( homeDirPath , " revive.toml") , []byte ("\n " ), 0644 )
50
51
t .Setenv ("HOME" , homeDirPath )
51
52
52
53
got := buildDefaultConfigPath ()
53
- want := homeDirPath + "/ revive.toml"
54
+ want := filepath . Join ( homeDirPath , " revive.toml")
54
55
55
56
if got != want {
56
57
t .Errorf ("got %q, wanted %q" , got , want )
@@ -59,14 +60,14 @@ func TestHomeConfigDir(t *testing.T) {
59
60
60
61
func TestXDGConfigDir (t * testing.T ) {
61
62
t .Cleanup (func () { AppFs = afero .NewMemMapFs () })
62
- xdgDirPath := "/tmp-iofs/xdg/config"
63
+ xdgDirPath := filepath . FromSlash ( "/tmp-iofs/xdg/config" )
63
64
AppFs .MkdirAll (xdgDirPath , 0755 )
64
65
65
- afero .WriteFile (AppFs , xdgDirPath + "/ revive.toml" , []byte ("\n " ), 0644 )
66
+ afero .WriteFile (AppFs , filepath . Join ( xdgDirPath , " revive.toml") , []byte ("\n " ), 0644 )
66
67
t .Setenv ("XDG_CONFIG_HOME" , xdgDirPath )
67
68
68
69
got := buildDefaultConfigPath ()
69
- want := xdgDirPath + "/ revive.toml"
70
+ want := filepath . Join ( xdgDirPath , " revive.toml")
70
71
71
72
if got != want {
72
73
t .Errorf ("got %q, wanted %q" , got , want )
@@ -75,7 +76,7 @@ func TestXDGConfigDir(t *testing.T) {
75
76
76
77
func TestXDGConfigDirNoFile (t * testing.T ) {
77
78
t .Cleanup (func () { AppFs = afero .NewMemMapFs () })
78
- xdgDirPath := "/tmp-iofs/xdg/config"
79
+ xdgDirPath := filepath . FromSlash ( "/tmp-iofs/xdg/config" )
79
80
t .Setenv ("XDG_CONFIG_HOME" , xdgDirPath )
80
81
81
82
got := buildDefaultConfigPath ()
0 commit comments