Skip to content

Commit

Permalink
🐛 fix(fs): fix test error on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Feb 25, 2023
1 parent c9dcde9 commit f290bee
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fsutil/fsutil_test.go
Expand Up @@ -2,6 +2,7 @@ package fsutil_test

import (
"bytes"
"runtime"
"testing"

"github.com/gookit/goutil/fsutil"
Expand Down Expand Up @@ -37,7 +38,12 @@ func TestTempDir(t *testing.T) {
}

func TestRealpath(t *testing.T) {
assert.Eq(t, "/path/to/dir", fsutil.Realpath("/path/to/some/../dir"))
inPath := "/path/to/some/../dir"
if runtime.GOOS == "windows" {
assert.Eq(t, "\\path\\to\\dir", fsutil.Realpath(inPath))
} else {
assert.Eq(t, "/path/to/dir", fsutil.Realpath(inPath))
}

dir, file := fsutil.SplitPath("/path/to/dir/some.txt")
assert.Eq(t, "/path/to/dir/", dir)
Expand Down

0 comments on commit f290bee

Please sign in to comment.