fix: folder style not using folder_separator_icon

This commit is contained in:
TravisTX 2021-01-03 09:21:17 -07:00 committed by Jan De Dobbeleer
parent 9822227a5e
commit 94ae5ed0b4
2 changed files with 38 additions and 22 deletions

View file

@ -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 {

View file

@ -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) {