mirror of
https://github.com/mgechev/revive.git
synced 2025-01-06 03:04:06 +02:00
chore: enable test shuffle and fix TestXDGConfigDirNoFile
This commit is contained in:
parent
2ae682968f
commit
78c3a6c363
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
@ -22,4 +22,4 @@ jobs:
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: Run tests
|
||||
run: go test -race ./...
|
||||
run: go test -race -shuffle=on ./...
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
@ -11,10 +12,11 @@ func TestMain(m *testing.M) {
|
||||
os.Unsetenv("HOME")
|
||||
os.Unsetenv("XDG_CONFIG_HOME")
|
||||
AppFs = afero.NewMemMapFs()
|
||||
homedir.DisableCache = true
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func TestXDGConfigDirIsPrefferedFirst(t *testing.T) {
|
||||
func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
|
||||
t.Cleanup(func() {
|
||||
// reset fs after test
|
||||
AppFs = afero.NewMemMapFs()
|
||||
@ -40,6 +42,7 @@ func TestXDGConfigDirIsPrefferedFirst(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHomeConfigDir(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
homeDirPath := "/tmp-iofs/home/tester"
|
||||
AppFs.MkdirAll(homeDirPath, 0755)
|
||||
|
||||
@ -55,6 +58,7 @@ func TestHomeConfigDir(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestXDGConfigDir(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
xdgDirPath := "/tmp-iofs/xdg/config"
|
||||
AppFs.MkdirAll(xdgDirPath, 0755)
|
||||
|
||||
@ -70,11 +74,12 @@ func TestXDGConfigDir(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestXDGConfigDirNoFile(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
xdgDirPath := "/tmp-iofs/xdg/config"
|
||||
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
want := xdgDirPath + "/revive.toml"
|
||||
want := ""
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %q, wanted %q", got, want)
|
||||
|
Loading…
Reference in New Issue
Block a user