Skip to content

Commit

Permalink
🐛 fix: sys - UserXXDir func test error on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 9, 2024
1 parent 7ae8ce4 commit 83393ca
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions sysutil/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,31 @@ func TestUserDir(t *testing.T) {
assert.NotEmpty(t, dir2)
assert.Eq(t, dir1, dir2)

dir = sysutil.UserDir("sub-path")
assert.Contains(t, dir, "/sub-path")
dump.P(dir)
if sysutil.IsWin() {
dir = sysutil.UserDir("sub-path")
assert.Contains(t, dir, "\\sub-path")
dump.P(dir)

dir = sysutil.UserCacheDir("my-logs")
assert.Contains(t, dir, ".cache/my-logs")
dump.P(dir)
dir = sysutil.UserCacheDir("my-logs")
assert.Contains(t, dir, ".cache\\my-logs")
dump.P(dir)

dir = sysutil.UserConfigDir("my-conf")
assert.Contains(t, dir, ".config/my-conf")
dump.P(dir)
dir = sysutil.UserConfigDir("my-conf")
assert.Contains(t, dir, ".config\\my-conf")
dump.P(dir)
} else {
dir = sysutil.UserDir("sub-path")
assert.Contains(t, dir, "/sub-path")
dump.P(dir)

dir = sysutil.UserCacheDir("my-logs")
assert.Contains(t, dir, ".cache/my-logs")
dump.P(dir)

dir = sysutil.UserConfigDir("my-conf")
assert.Contains(t, dir, ".config/my-conf")
dump.P(dir)
}

rawPath := "~/.kite"
assert.LenGt(t, sysutil.ExpandPath(rawPath), len(rawPath))
Expand Down

0 comments on commit 83393ca

Please sign in to comment.