Skip to content

Commit 78c3a6c

Browse files
alexandearchavacava
authored andcommitted
chore: enable test shuffle and fix TestXDGConfigDirNoFile
1 parent 2ae6829 commit 78c3a6c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
with:
2323
go-version: ${{ matrix.go-version }}
2424
- name: Run tests
25-
run: go test -race ./...
25+
run: go test -race -shuffle=on ./...

cli/main_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import (
44
"os"
55
"testing"
66

7+
"github.com/mitchellh/go-homedir"
78
"github.com/spf13/afero"
89
)
910

1011
func TestMain(m *testing.M) {
1112
os.Unsetenv("HOME")
1213
os.Unsetenv("XDG_CONFIG_HOME")
1314
AppFs = afero.NewMemMapFs()
15+
homedir.DisableCache = true
1416
os.Exit(m.Run())
1517
}
1618

17-
func TestXDGConfigDirIsPrefferedFirst(t *testing.T) {
19+
func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
1820
t.Cleanup(func() {
1921
// reset fs after test
2022
AppFs = afero.NewMemMapFs()
@@ -40,6 +42,7 @@ func TestXDGConfigDirIsPrefferedFirst(t *testing.T) {
4042
}
4143

4244
func TestHomeConfigDir(t *testing.T) {
45+
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
4346
homeDirPath := "/tmp-iofs/home/tester"
4447
AppFs.MkdirAll(homeDirPath, 0755)
4548

@@ -55,6 +58,7 @@ func TestHomeConfigDir(t *testing.T) {
5558
}
5659

5760
func TestXDGConfigDir(t *testing.T) {
61+
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
5862
xdgDirPath := "/tmp-iofs/xdg/config"
5963
AppFs.MkdirAll(xdgDirPath, 0755)
6064

@@ -70,11 +74,12 @@ func TestXDGConfigDir(t *testing.T) {
7074
}
7175

7276
func TestXDGConfigDirNoFile(t *testing.T) {
77+
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
7378
xdgDirPath := "/tmp-iofs/xdg/config"
7479
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
7580

7681
got := buildDefaultConfigPath()
77-
want := xdgDirPath + "/revive.toml"
82+
want := ""
7883

7984
if got != want {
8085
t.Errorf("got %q, wanted %q", got, want)

0 commit comments

Comments
 (0)