mirror of
https://github.com/spf13/viper
synced 2024-12-22 11:37:02 +00:00
test: fix tests on windows
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
164252315d
commit
d59cc8b6cd
2 changed files with 5 additions and 3 deletions
2
file.go
2
file.go
|
@ -53,6 +53,8 @@ func (v *Viper) findConfigFileWithFinder(finder Finder) (string, error) {
|
||||||
return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)}
|
return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We call clean on the final result to ensure that the path is in its canonical form.
|
||||||
|
// This is mostly for consistent path handling and to make sure tests pass.
|
||||||
return results[0], nil
|
return results[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,10 +368,10 @@ func TestGetConfigFile(t *testing.T) {
|
||||||
t.Run("using a finder", func(t *testing.T) {
|
t.Run("using a finder", func(t *testing.T) {
|
||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
|
|
||||||
err := fs.Mkdir(testutil.AbsFilePath(t, "/etc/viper"), 0o777)
|
err := fs.Mkdir("/etc/viper", 0o777)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = fs.Create(testutil.AbsFilePath(t, "/etc/viper/config.yaml"))
|
_, err = fs.Create("/etc/viper/config.yaml")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
finder := locafero.Finder{
|
finder := locafero.Finder{
|
||||||
|
@ -389,7 +389,7 @@ func TestGetConfigFile(t *testing.T) {
|
||||||
v.SetConfigName("not-config")
|
v.SetConfigName("not-config")
|
||||||
|
|
||||||
filename, err := v.getConfigFile()
|
filename, err := v.getConfigFile()
|
||||||
assert.Equal(t, testutil.AbsFilePath(t, "/etc/viper/config.yaml"), filename)
|
assert.Equal(t, "/etc/viper/config.yaml", filename)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue