mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
fix: folder style not using folder_separator_icon
This commit is contained in:
parent
9822227a5e
commit
94ae5ed0b4
|
@ -115,7 +115,8 @@ func (pt *path) getFullPath() string {
|
|||
|
||||
func (pt *path) getFolderPath() string {
|
||||
pwd := pt.getPwd()
|
||||
return base(pwd, pt.env)
|
||||
pwd = base(pwd, pt.env)
|
||||
return pt.replaceFolderSeparators(pwd)
|
||||
}
|
||||
|
||||
func (pt *path) getPwd() string {
|
||||
|
|
|
@ -449,6 +449,7 @@ func TestGetAgnosterShortPathOneLevel(t *testing.T) {
|
|||
assert.Equal(t, "foo", got)
|
||||
}
|
||||
|
||||
// nolint:dupl // false positive
|
||||
func TestGetFullPath(t *testing.T) {
|
||||
cases := []struct {
|
||||
UseFolderSeparatorIcon bool
|
||||
|
@ -488,30 +489,44 @@ func TestGetFullPath(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// nolint:dupl // false positive
|
||||
func TestGetFolderPath(t *testing.T) {
|
||||
pwd := "/usr/home/projects"
|
||||
env := new(MockedEnvironment)
|
||||
env.On("getPathSeperator", nil).Return("/")
|
||||
env.On("homeDir", nil).Return("/usr/home")
|
||||
env.On("getcwd", nil).Return(pwd)
|
||||
path := &path{
|
||||
env: env,
|
||||
}
|
||||
got := path.getFolderPath()
|
||||
assert.Equal(t, "projects", got)
|
||||
}
|
||||
cases := []struct {
|
||||
UseFolderSeparatorIcon bool
|
||||
Pwd string
|
||||
Expected string
|
||||
}{
|
||||
{UseFolderSeparatorIcon: false, Pwd: "", Expected: "."},
|
||||
{UseFolderSeparatorIcon: false, Pwd: "/", Expected: "/"},
|
||||
{UseFolderSeparatorIcon: false, Pwd: "/usr/home", Expected: "~"},
|
||||
{UseFolderSeparatorIcon: false, Pwd: "/usr/home/abc", Expected: "abc"},
|
||||
{UseFolderSeparatorIcon: false, Pwd: "/a/b/c/d", Expected: "d"},
|
||||
|
||||
func TestGetFolderPathInsideHome(t *testing.T) {
|
||||
pwd := "/usr/home"
|
||||
env := new(MockedEnvironment)
|
||||
env.On("getPathSeperator", nil).Return("/")
|
||||
env.On("homeDir", nil).Return("/usr/home")
|
||||
env.On("getcwd", nil).Return(pwd)
|
||||
path := &path{
|
||||
env: env,
|
||||
{UseFolderSeparatorIcon: true, Pwd: "", Expected: "."},
|
||||
{UseFolderSeparatorIcon: true, Pwd: "/", Expected: "|"},
|
||||
{UseFolderSeparatorIcon: true, Pwd: "/usr/home", Expected: "~"},
|
||||
{UseFolderSeparatorIcon: true, Pwd: "/usr/home/abc", Expected: "abc"},
|
||||
{UseFolderSeparatorIcon: true, Pwd: "/a/b/c/d", Expected: "d"},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
env := new(MockedEnvironment)
|
||||
env.On("getPathSeperator", nil).Return("/")
|
||||
env.On("homeDir", nil).Return("/usr/home")
|
||||
env.On("getcwd", nil).Return(tc.Pwd)
|
||||
props := map[Property]interface{}{}
|
||||
if tc.UseFolderSeparatorIcon {
|
||||
props[FolderSeparatorIcon] = "|"
|
||||
}
|
||||
path := &path{
|
||||
env: env,
|
||||
props: &properties{
|
||||
values: props,
|
||||
},
|
||||
}
|
||||
got := path.getFolderPath()
|
||||
assert.Equal(t, tc.Expected, got)
|
||||
}
|
||||
got := path.getFolderPath()
|
||||
assert.Equal(t, "~", got)
|
||||
}
|
||||
|
||||
func TestGetFolderPathCustomMappedLocations(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue