Skip to content

Commit 34ec0b8

Browse files
authored
Use homedir for realpath test (#615)
1 parent 677e0f3 commit 34ec0b8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

internal/vfs/osvfs/os_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ func TestOS(t *testing.T) {
1818

1919
fs := osvfs.FS()
2020

21-
goMod := filepath.Join(repo.RootPath, "go.mod")
22-
goModPath := tspath.NormalizePath(goMod)
23-
2421
t.Run("ReadFile", func(t *testing.T) {
2522
t.Parallel()
2623

24+
goMod := filepath.Join(repo.RootPath, "go.mod")
25+
goModPath := tspath.NormalizePath(goMod)
26+
2727
expectedRaw, err := os.ReadFile(goMod)
2828
assert.NilError(t, err)
2929
expected := string(expectedRaw)
@@ -36,12 +36,18 @@ func TestOS(t *testing.T) {
3636
t.Run("Realpath", func(t *testing.T) {
3737
t.Parallel()
3838

39-
expected := goModPath
39+
home, err := os.UserHomeDir()
40+
if err != nil {
41+
t.Skip(err)
42+
}
43+
home = tspath.NormalizePath(home)
44+
45+
expected := home
4046
if runtime.GOOS == "windows" {
4147
// Windows drive letters can be lowercase, but realpath will always return uppercase.
4248
expected = strings.ToUpper(expected[:1]) + expected[1:]
4349
}
44-
realpath := fs.Realpath(goModPath)
50+
realpath := fs.Realpath(home)
4551
assert.Equal(t, realpath, expected)
4652
})
4753

0 commit comments

Comments
 (0)