Skip to content

Commit

Permalink
test: fix tests on windows
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <[email protected]>
  • Loading branch information
sagikazarmark committed Jun 4, 2024
1 parent 54e781a commit 89add5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func (v *Viper) findConfigFileWithFinder(finder Finder) (string, error) {
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
}

Expand Down
6 changes: 3 additions & 3 deletions viper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,10 @@ func TestGetConfigFile(t *testing.T) {
t.Run("using a finder", func(t *testing.T) {
fs := afero.NewMemMapFs()

err := fs.Mkdir(testutil.AbsFilePath(t, "/etc/viper"), 0o777)
err := fs.Mkdir("/etc/viper", 0o777)
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)

finder := locafero.Finder{
Expand All @@ -389,7 +389,7 @@ func TestGetConfigFile(t *testing.T) {
v.SetConfigName("not-config")

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)
})
}
Expand Down

0 comments on commit 89add5f

Please sign in to comment.