@@ -449,6 +449,7 @@ func TestGetAgnosterShortPathOneLevel(t *testing.T) {
449449 assert .Equal (t , "foo" , got )
450450}
451451
452+ // nolint:dupl // false positive
452453func TestGetFullPath (t * testing.T ) {
453454 cases := []struct {
454455 UseFolderSeparatorIcon bool
@@ -488,30 +489,44 @@ func TestGetFullPath(t *testing.T) {
488489 }
489490}
490491
492+ // nolint:dupl // false positive
491493func TestGetFolderPath (t * testing.T ) {
492- pwd := "/usr/home/projects"
493- env := new (MockedEnvironment )
494- env .On ("getPathSeperator" , nil ).Return ("/" )
495- env .On ("homeDir" , nil ).Return ("/usr/home" )
496- env .On ("getcwd" , nil ).Return (pwd )
497- path := & path {
498- env : env ,
494+ cases := []struct {
495+ UseFolderSeparatorIcon bool
496+ Pwd string
497+ Expected string
498+ }{
499+ {UseFolderSeparatorIcon : false , Pwd : "" , Expected : "." },
500+ {UseFolderSeparatorIcon : false , Pwd : "/" , Expected : "/" },
501+ {UseFolderSeparatorIcon : false , Pwd : "/usr/home" , Expected : "~" },
502+ {UseFolderSeparatorIcon : false , Pwd : "/usr/home/abc" , Expected : "abc" },
503+ {UseFolderSeparatorIcon : false , Pwd : "/a/b/c/d" , Expected : "d" },
504+
505+ {UseFolderSeparatorIcon : true , Pwd : "" , Expected : "." },
506+ {UseFolderSeparatorIcon : true , Pwd : "/" , Expected : "|" },
507+ {UseFolderSeparatorIcon : true , Pwd : "/usr/home" , Expected : "~" },
508+ {UseFolderSeparatorIcon : true , Pwd : "/usr/home/abc" , Expected : "abc" },
509+ {UseFolderSeparatorIcon : true , Pwd : "/a/b/c/d" , Expected : "d" },
499510 }
500- got := path .getFolderPath ()
501- assert .Equal (t , "projects" , got )
502- }
503511
504- func TestGetFolderPathInsideHome (t * testing.T ) {
505- pwd := "/usr/home"
506- env := new (MockedEnvironment )
507- env .On ("getPathSeperator" , nil ).Return ("/" )
508- env .On ("homeDir" , nil ).Return ("/usr/home" )
509- env .On ("getcwd" , nil ).Return (pwd )
510- path := & path {
511- env : env ,
512+ for _ , tc := range cases {
513+ env := new (MockedEnvironment )
514+ env .On ("getPathSeperator" , nil ).Return ("/" )
515+ env .On ("homeDir" , nil ).Return ("/usr/home" )
516+ env .On ("getcwd" , nil ).Return (tc .Pwd )
517+ props := map [Property ]interface {}{}
518+ if tc .UseFolderSeparatorIcon {
519+ props [FolderSeparatorIcon ] = "|"
520+ }
521+ path := & path {
522+ env : env ,
523+ props : & properties {
524+ values : props ,
525+ },
526+ }
527+ got := path .getFolderPath ()
528+ assert .Equal (t , tc .Expected , got )
512529 }
513- got := path .getFolderPath ()
514- assert .Equal (t , "~" , got )
515530}
516531
517532func TestGetFolderPathCustomMappedLocations (t * testing.T ) {
0 commit comments