Skip to content

Commit

Permalink
Add test case for internal ExpandHome on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
adrg committed Oct 24, 2021
1 parent 50902f6 commit 09084b8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/util/paths_windows_test.go
Expand Up @@ -4,6 +4,7 @@
package util_test

import (
"path/filepath"
"testing"

"github.com/adrg/xdg/internal/util"
Expand All @@ -18,3 +19,16 @@ func TestKnownFolderPath(t *testing.T) {
require.Equal(t, expected, util.KnownFolderPath(nil, nil, []string{expected}))
require.Equal(t, "", util.KnownFolderPath(nil, nil, nil))
}

func TestExpandHome(t *testing.T) {
home := `C:\Users\test`

require.Equal(t, home, util.ExpandHome(`%USERPROFILE%`, home))
require.Equal(t, filepath.Join(home, "appname"), util.ExpandHome(`%USERPROFILE%\appname`, home))

require.Equal(t, "", util.ExpandHome("", home))
require.Equal(t, home, util.ExpandHome(home, ""))
require.Equal(t, "", util.ExpandHome("", ""))

require.Equal(t, home, util.ExpandHome(home, home))
}

0 comments on commit 09084b8

Please sign in to comment.