mirror of
https://github.com/mgechev/revive.git
synced 2025-07-17 01:12:27 +02:00
fix: cli tests on Windows; add tests-on-windows workflow
This commit is contained in:
committed by
chavacava
parent
74e2417f7d
commit
ce6965265a
@ -2,6 +2,7 @@ package cli
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
@ -22,19 +23,19 @@ func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
|
||||
AppFs = afero.NewMemMapFs()
|
||||
})
|
||||
|
||||
xdgDirPath := "/tmp-iofs/xdg/config"
|
||||
homeDirPath := "/tmp-iofs/home/tester"
|
||||
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
|
||||
homeDirPath := filepath.FromSlash("/tmp-iofs/home/tester")
|
||||
AppFs.MkdirAll(xdgDirPath, 0755)
|
||||
AppFs.MkdirAll(homeDirPath, 0755)
|
||||
|
||||
afero.WriteFile(AppFs, xdgDirPath+"/revive.toml", []byte("\n"), 0644)
|
||||
afero.WriteFile(AppFs, filepath.Join(xdgDirPath, "revive.toml"), []byte("\n"), 0644)
|
||||
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
|
||||
|
||||
afero.WriteFile(AppFs, homeDirPath+"/revive.toml", []byte("\n"), 0644)
|
||||
afero.WriteFile(AppFs, filepath.Join(homeDirPath, "revive.toml"), []byte("\n"), 0644)
|
||||
t.Setenv("HOME", homeDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
want := xdgDirPath + "/revive.toml"
|
||||
want := filepath.Join(xdgDirPath, "revive.toml")
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %q, wanted %q", got, want)
|
||||
@ -43,14 +44,14 @@ func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
|
||||
|
||||
func TestHomeConfigDir(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
homeDirPath := "/tmp-iofs/home/tester"
|
||||
homeDirPath := filepath.FromSlash("/tmp-iofs/home/tester")
|
||||
AppFs.MkdirAll(homeDirPath, 0755)
|
||||
|
||||
afero.WriteFile(AppFs, homeDirPath+"/revive.toml", []byte("\n"), 0644)
|
||||
afero.WriteFile(AppFs, filepath.Join(homeDirPath, "revive.toml"), []byte("\n"), 0644)
|
||||
t.Setenv("HOME", homeDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
want := homeDirPath + "/revive.toml"
|
||||
want := filepath.Join(homeDirPath, "revive.toml")
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %q, wanted %q", got, want)
|
||||
@ -59,14 +60,14 @@ func TestHomeConfigDir(t *testing.T) {
|
||||
|
||||
func TestXDGConfigDir(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
xdgDirPath := "/tmp-iofs/xdg/config"
|
||||
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
|
||||
AppFs.MkdirAll(xdgDirPath, 0755)
|
||||
|
||||
afero.WriteFile(AppFs, xdgDirPath+"/revive.toml", []byte("\n"), 0644)
|
||||
afero.WriteFile(AppFs, filepath.Join(xdgDirPath, "revive.toml"), []byte("\n"), 0644)
|
||||
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
want := xdgDirPath + "/revive.toml"
|
||||
want := filepath.Join(xdgDirPath, "revive.toml")
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %q, wanted %q", got, want)
|
||||
@ -75,7 +76,7 @@ func TestXDGConfigDir(t *testing.T) {
|
||||
|
||||
func TestXDGConfigDirNoFile(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
xdgDirPath := "/tmp-iofs/xdg/config"
|
||||
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
|
||||
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
|
Reference in New Issue
Block a user