mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
parent
e62482c56f
commit
3d4fc5b6dd
|
@ -16,17 +16,17 @@ func TestGetTitle(t *testing.T) {
|
|||
Root bool
|
||||
User string
|
||||
Cwd string
|
||||
PathSeperator string
|
||||
PathSeparator string
|
||||
ShellName string
|
||||
Expected string
|
||||
}{
|
||||
{Style: FolderName, Cwd: "/usr/home", PathSeperator: "/", ShellName: "default", Expected: "\x1b]0;~\a"},
|
||||
{Style: FullPath, Cwd: "/usr/home/jan", PathSeperator: "/", ShellName: "default", Expected: "\x1b]0;~/jan\a"},
|
||||
{Style: FolderName, Cwd: "/usr/home", PathSeparator: "/", ShellName: "default", Expected: "\x1b]0;~\a"},
|
||||
{Style: FullPath, Cwd: "/usr/home/jan", PathSeparator: "/", ShellName: "default", Expected: "\x1b]0;~/jan\a"},
|
||||
{
|
||||
Style: Template,
|
||||
Template: "{{.Env.USERDOMAIN}} :: {{.PWD}}{{if .Root}} :: Admin{{end}} :: {{.Shell}}",
|
||||
Cwd: "C:\\vagrant",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
ShellName: "PowerShell",
|
||||
Root: true,
|
||||
Expected: "\x1b]0;MyCompany :: C:\\vagrant :: Admin :: PowerShell\a",
|
||||
|
@ -35,7 +35,7 @@ func TestGetTitle(t *testing.T) {
|
|||
Style: Template,
|
||||
Template: "{{.Folder}}{{if .Root}} :: Admin{{end}} :: {{.Shell}}",
|
||||
Cwd: "C:\\vagrant",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
ShellName: "PowerShell",
|
||||
Expected: "\x1b]0;vagrant :: PowerShell\a",
|
||||
},
|
||||
|
@ -44,7 +44,7 @@ func TestGetTitle(t *testing.T) {
|
|||
Template: "{{.UserName}}@{{.HostName}}{{if .Root}} :: Admin{{end}} :: {{.Shell}}",
|
||||
Root: true,
|
||||
User: "MyUser",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
ShellName: "PowerShell",
|
||||
Expected: "\x1b]0;MyUser@MyHost :: Admin :: PowerShell\a",
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ func TestGetTitle(t *testing.T) {
|
|||
env := new(mock.MockedEnvironment)
|
||||
env.On("Pwd").Return(tc.Cwd)
|
||||
env.On("Home").Return("/usr/home")
|
||||
env.On("PathSeperator").Return(tc.PathSeperator)
|
||||
env.On("PathSeparator").Return(tc.PathSeparator)
|
||||
env.On("TemplateCache").Return(&environment.TemplateCache{
|
||||
Env: map[string]string{
|
||||
"USERDOMAIN": "MyCompany",
|
||||
|
@ -86,7 +86,7 @@ func TestGetConsoleTitleIfGethostnameReturnsError(t *testing.T) {
|
|||
Root bool
|
||||
User string
|
||||
Cwd string
|
||||
PathSeperator string
|
||||
PathSeparator string
|
||||
ShellName string
|
||||
Expected string
|
||||
}{
|
||||
|
@ -94,7 +94,7 @@ func TestGetConsoleTitleIfGethostnameReturnsError(t *testing.T) {
|
|||
Style: Template,
|
||||
Template: "Not using Host only {{.UserName}} and {{.Shell}}",
|
||||
User: "MyUser",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
ShellName: "PowerShell",
|
||||
Expected: "\x1b]0;Not using Host only MyUser and PowerShell\a",
|
||||
},
|
||||
|
@ -102,7 +102,7 @@ func TestGetConsoleTitleIfGethostnameReturnsError(t *testing.T) {
|
|||
Style: Template,
|
||||
Template: "{{.UserName}}@{{.HostName}} :: {{.Shell}}",
|
||||
User: "MyUser",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
ShellName: "PowerShell",
|
||||
Expected: "\x1b]0;MyUser@ :: PowerShell\a",
|
||||
},
|
||||
|
|
|
@ -145,7 +145,7 @@ type Environment interface {
|
|||
Shell() string
|
||||
Platform() string
|
||||
ErrorCode() int
|
||||
PathSeperator() string
|
||||
PathSeparator() string
|
||||
HasFiles(pattern string) bool
|
||||
HasFilesInDir(dir, pattern string) bool
|
||||
HasFolder(folder string) bool
|
||||
|
@ -300,7 +300,7 @@ func (env *ShellEnvironment) Pwd() string {
|
|||
func (env *ShellEnvironment) HasFiles(pattern string) bool {
|
||||
defer env.trace(time.Now(), "HasFiles", pattern)
|
||||
cwd := env.Pwd()
|
||||
pattern = cwd + env.PathSeperator() + pattern
|
||||
pattern = cwd + env.PathSeparator() + pattern
|
||||
matches, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
env.log(Error, "HasFiles", err.Error())
|
||||
|
@ -311,7 +311,7 @@ func (env *ShellEnvironment) HasFiles(pattern string) bool {
|
|||
|
||||
func (env *ShellEnvironment) HasFilesInDir(dir, pattern string) bool {
|
||||
defer env.trace(time.Now(), "HasFilesInDir", pattern)
|
||||
pattern = dir + env.PathSeperator() + pattern
|
||||
pattern = dir + env.PathSeparator() + pattern
|
||||
matches, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
env.log(Error, "HasFilesInDir", err.Error())
|
||||
|
@ -371,8 +371,8 @@ func (env *ShellEnvironment) FolderList(path string) []string {
|
|||
return folderNames
|
||||
}
|
||||
|
||||
func (env *ShellEnvironment) PathSeperator() string {
|
||||
defer env.trace(time.Now(), "PathSeperator")
|
||||
func (env *ShellEnvironment) PathSeparator() string {
|
||||
defer env.trace(time.Now(), "PathSeparator")
|
||||
return string(os.PathSeparator)
|
||||
}
|
||||
|
||||
|
@ -698,7 +698,7 @@ func Base(env Environment, path string) string {
|
|||
}
|
||||
volumeName := filepath.VolumeName(path)
|
||||
// Strip trailing slashes.
|
||||
for len(path) > 0 && string(path[len(path)-1]) == env.PathSeperator() {
|
||||
for len(path) > 0 && string(path[len(path)-1]) == env.PathSeparator() {
|
||||
path = path[0 : len(path)-1]
|
||||
}
|
||||
if volumeName == path {
|
||||
|
@ -708,7 +708,7 @@ func Base(env Environment, path string) string {
|
|||
path = path[len(filepath.VolumeName(path)):]
|
||||
// Find the last element
|
||||
i := len(path) - 1
|
||||
for i >= 0 && string(path[i]) != env.PathSeperator() {
|
||||
for i >= 0 && string(path[i]) != env.PathSeparator() {
|
||||
i--
|
||||
}
|
||||
if i >= 0 {
|
||||
|
@ -716,7 +716,7 @@ func Base(env Environment, path string) string {
|
|||
}
|
||||
// If empty now, it had only slashes.
|
||||
if path == "" {
|
||||
return env.PathSeperator()
|
||||
return env.PathSeparator()
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func (env *MockedEnvironment) FolderList(path string) []string {
|
|||
return args.Get(0).([]string)
|
||||
}
|
||||
|
||||
func (env *MockedEnvironment) PathSeperator() string {
|
||||
func (env *MockedEnvironment) PathSeparator() string {
|
||||
args := env.Called()
|
||||
return args.String(0)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestDotnetSegment(t *testing.T) {
|
|||
}
|
||||
|
||||
env.On("HasFiles", "*.cs").Return(true)
|
||||
env.On("PathSeperator").Return("")
|
||||
env.On("PathSeparator").Return("")
|
||||
env.On("Pwd").Return("/usr/home/project")
|
||||
env.On("Home").Return("/usr/home")
|
||||
env.On("TemplateCache").Return(&environment.TemplateCache{
|
||||
|
|
|
@ -115,7 +115,7 @@ func (pt *Path) Init(props properties.Properties, env environment.Environment) {
|
|||
func (pt *Path) getMixedPath() string {
|
||||
var buffer strings.Builder
|
||||
pwd := pt.getPwd()
|
||||
splitted := strings.Split(pwd, pt.env.PathSeperator())
|
||||
splitted := strings.Split(pwd, pt.env.PathSeparator())
|
||||
threshold := int(pt.props.GetFloat64(MixedThreshold, 4))
|
||||
for i, part := range splitted {
|
||||
if part == "" {
|
||||
|
@ -126,7 +126,7 @@ func (pt *Path) getMixedPath() string {
|
|||
if len(part) > threshold && i != 0 && i != len(splitted)-1 {
|
||||
folder = pt.props.GetString(FolderIcon, "..")
|
||||
}
|
||||
separator := pt.props.GetString(FolderSeparatorIcon, pt.env.PathSeperator())
|
||||
separator := pt.props.GetString(FolderSeparatorIcon, pt.env.PathSeparator())
|
||||
if i == 0 {
|
||||
separator = ""
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ func (pt *Path) getAgnosterPath() string {
|
|||
buffer.WriteString(pt.rootLocation())
|
||||
pathDepth := pt.pathDepth(pwd)
|
||||
folderIcon := pt.props.GetString(FolderIcon, "..")
|
||||
separator := pt.props.GetString(FolderSeparatorIcon, pt.env.PathSeperator())
|
||||
separator := pt.props.GetString(FolderSeparatorIcon, pt.env.PathSeparator())
|
||||
for i := 1; i < pathDepth; i++ {
|
||||
buffer.WriteString(fmt.Sprintf("%s%s", separator, folderIcon))
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func (pt *Path) getAgnosterPath() string {
|
|||
|
||||
func (pt *Path) getAgnosterLeftPath() string {
|
||||
pwd := pt.getPwd()
|
||||
separator := pt.env.PathSeperator()
|
||||
separator := pt.env.PathSeparator()
|
||||
pwd = strings.Trim(pwd, separator)
|
||||
splitted := strings.Split(pwd, separator)
|
||||
folderIcon := pt.props.GetString(FolderIcon, "..")
|
||||
|
@ -191,8 +191,8 @@ func (pt *Path) getRelevantLetter(folder string) string {
|
|||
func (pt *Path) getLetterPath() string {
|
||||
var buffer strings.Builder
|
||||
pwd := pt.getPwd()
|
||||
splitted := strings.Split(pwd, pt.env.PathSeperator())
|
||||
separator := pt.props.GetString(FolderSeparatorIcon, pt.env.PathSeperator())
|
||||
splitted := strings.Split(pwd, pt.env.PathSeparator())
|
||||
separator := pt.props.GetString(FolderSeparatorIcon, pt.env.PathSeparator())
|
||||
for i := 0; i < len(splitted)-1; i++ {
|
||||
folder := splitted[i]
|
||||
if len(folder) == 0 {
|
||||
|
@ -210,8 +210,8 @@ func (pt *Path) getLetterPath() string {
|
|||
func (pt *Path) getUniqueLettersPath() string {
|
||||
var buffer strings.Builder
|
||||
pwd := pt.getPwd()
|
||||
splitted := strings.Split(pwd, pt.env.PathSeperator())
|
||||
separator := pt.props.GetString(FolderSeparatorIcon, pt.env.PathSeperator())
|
||||
splitted := strings.Split(pwd, pt.env.PathSeparator())
|
||||
separator := pt.props.GetString(FolderSeparatorIcon, pt.env.PathSeparator())
|
||||
letters := make(map[string]bool, len(splitted))
|
||||
for i := 0; i < len(splitted)-1; i++ {
|
||||
folder := splitted[i]
|
||||
|
@ -236,7 +236,7 @@ func (pt *Path) getUniqueLettersPath() string {
|
|||
|
||||
func (pt *Path) getAgnosterFullPath() string {
|
||||
pwd := pt.getPwd()
|
||||
if len(pwd) > 1 && string(pwd[0]) == pt.env.PathSeperator() {
|
||||
if len(pwd) > 1 && string(pwd[0]) == pt.env.PathSeparator() {
|
||||
pwd = pwd[1:]
|
||||
}
|
||||
return pt.replaceFolderSeparators(pwd)
|
||||
|
@ -252,7 +252,7 @@ func (pt *Path) getAgnosterShortPath() string {
|
|||
if pathDepth <= maxDepth {
|
||||
return pt.getAgnosterFullPath()
|
||||
}
|
||||
pathSeparator := pt.env.PathSeperator()
|
||||
pathSeparator := pt.env.PathSeparator()
|
||||
folderSeparator := pt.props.GetString(FolderSeparatorIcon, pathSeparator)
|
||||
folderIcon := pt.props.GetString(FolderIcon, "..")
|
||||
root := pt.rootLocation()
|
||||
|
@ -341,7 +341,7 @@ func (pt *Path) replaceMappedLocations(pwd string) string {
|
|||
}
|
||||
|
||||
func (pt *Path) replaceFolderSeparators(pwd string) string {
|
||||
defaultSeparator := pt.env.PathSeperator()
|
||||
defaultSeparator := pt.env.PathSeparator()
|
||||
if pwd == defaultSeparator {
|
||||
return pwd
|
||||
}
|
||||
|
@ -360,14 +360,14 @@ func (pt *Path) inHomeDir(pwd string) bool {
|
|||
|
||||
func (pt *Path) rootLocation() string {
|
||||
pwd := pt.getPwd()
|
||||
pwd = strings.TrimPrefix(pwd, pt.env.PathSeperator())
|
||||
splitted := strings.Split(pwd, pt.env.PathSeperator())
|
||||
pwd = strings.TrimPrefix(pwd, pt.env.PathSeparator())
|
||||
splitted := strings.Split(pwd, pt.env.PathSeparator())
|
||||
rootLocation := splitted[0]
|
||||
return rootLocation
|
||||
}
|
||||
|
||||
func (pt *Path) pathDepth(pwd string) int {
|
||||
splitted := strings.Split(pwd, pt.env.PathSeperator())
|
||||
splitted := strings.Split(pwd, pt.env.PathSeparator())
|
||||
depth := 0
|
||||
for _, part := range splitted {
|
||||
if part != "" {
|
||||
|
|
|
@ -75,18 +75,18 @@ func TestRootLocationHome(t *testing.T) {
|
|||
HomePath string
|
||||
Pswd string
|
||||
Pwd string
|
||||
PathSeperator string
|
||||
PathSeparator string
|
||||
HomeIcon string
|
||||
RegistryIcon string
|
||||
}{
|
||||
{Expected: "~", HomeIcon: "~", HomePath: "/home/bill/", Pwd: "/home/bill/", PathSeperator: "/"},
|
||||
{Expected: "usr", HomePath: "/home/bill/", Pwd: "/usr/error/what", PathSeperator: "/"},
|
||||
{Expected: "C:", HomePath: "C:\\Users\\Bill", Pwd: "C:\\Program Files\\Go", PathSeperator: "\\"},
|
||||
{Expected: "REG", RegistryIcon: "REG", HomePath: "C:\\Users\\Bill", Pwd: "HKCU:\\Program Files\\Go", PathSeperator: "\\"},
|
||||
{Expected: "~", HomeIcon: "~", HomePath: "C:\\Users\\Bill", Pwd: "Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Bill", PathSeperator: "\\"},
|
||||
{Expected: "C:", HomePath: "C:\\Users\\Jack", Pwd: "Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Bill", PathSeperator: "\\"},
|
||||
{Expected: "", HomePath: "C:\\Users\\Jack", Pwd: "", PathSeperator: "\\"},
|
||||
{Expected: "DRIVE:", HomePath: "/home/bill/", Pwd: "/usr/error/what", Pswd: "DRIVE:", PathSeperator: "/"},
|
||||
{Expected: "~", HomeIcon: "~", HomePath: "/home/bill/", Pwd: "/home/bill/", PathSeparator: "/"},
|
||||
{Expected: "usr", HomePath: "/home/bill/", Pwd: "/usr/error/what", PathSeparator: "/"},
|
||||
{Expected: "C:", HomePath: "C:\\Users\\Bill", Pwd: "C:\\Program Files\\Go", PathSeparator: "\\"},
|
||||
{Expected: "REG", RegistryIcon: "REG", HomePath: "C:\\Users\\Bill", Pwd: "HKCU:\\Program Files\\Go", PathSeparator: "\\"},
|
||||
{Expected: "~", HomeIcon: "~", HomePath: "C:\\Users\\Bill", Pwd: "Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Bill", PathSeparator: "\\"},
|
||||
{Expected: "C:", HomePath: "C:\\Users\\Jack", Pwd: "Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Bill", PathSeparator: "\\"},
|
||||
{Expected: "", HomePath: "C:\\Users\\Jack", Pwd: "", PathSeparator: "\\"},
|
||||
{Expected: "DRIVE:", HomePath: "/home/bill/", Pwd: "/usr/error/what", Pswd: "DRIVE:", PathSeparator: "/"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
env := new(mock.MockedEnvironment)
|
||||
|
@ -96,7 +96,7 @@ func TestRootLocationHome(t *testing.T) {
|
|||
PSWD: &tc.Pswd,
|
||||
}
|
||||
env.On("Args").Return(args)
|
||||
env.On("PathSeperator").Return(tc.PathSeperator)
|
||||
env.On("PathSeparator").Return(tc.PathSeparator)
|
||||
env.On("GOOS").Return("")
|
||||
path := &Path{
|
||||
env: env,
|
||||
|
@ -127,7 +127,7 @@ func TestPathDepthMultipleLevelsDeep(t *testing.T) {
|
|||
pwd += levelDir
|
||||
}
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return("/")
|
||||
env.On("PathSeparator").Return("/")
|
||||
env.On("getRunteGOOS").Return("")
|
||||
path := &Path{
|
||||
env: env,
|
||||
|
@ -139,7 +139,7 @@ func TestPathDepthMultipleLevelsDeep(t *testing.T) {
|
|||
func TestPathDepthZeroLevelsDeep(t *testing.T) {
|
||||
pwd := "/usr/"
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return("/")
|
||||
env.On("PathSeparator").Return("/")
|
||||
path := &Path{
|
||||
env: env,
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ func TestPathDepthZeroLevelsDeep(t *testing.T) {
|
|||
func TestPathDepthOneLevelDeep(t *testing.T) {
|
||||
pwd := "/usr/location"
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return("/")
|
||||
env.On("PathSeparator").Return("/")
|
||||
path := &Path{
|
||||
env: env,
|
||||
}
|
||||
|
@ -164,32 +164,32 @@ func TestAgnosterPathStyles(t *testing.T) {
|
|||
HomePath string
|
||||
Pswd string
|
||||
Pwd string
|
||||
PathSeperator string
|
||||
PathSeparator string
|
||||
HomeIcon string
|
||||
FolderSeparatorIcon string
|
||||
Style string
|
||||
GOOS string
|
||||
MaxDepth int
|
||||
}{
|
||||
{Style: AgnosterFull, Expected: "usr > location > whatever", HomePath: "/usr/home", Pwd: "/usr/location/whatever", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "usr > .. > man", HomePath: "/usr/home", Pwd: "/usr/location/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "~ > .. > man", HomePath: "/usr/home", Pwd: "/usr/home/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "~ > projects", HomePath: "/usr/home", Pwd: "/usr/home/projects", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "C:", HomePath: homeBillWindows, Pwd: "C:", PathSeperator: "\\", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "/", HomePath: homeBillWindows, Pwd: "/", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "foo", HomePath: homeBillWindows, Pwd: "/foo", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterFull, Expected: "usr > location > whatever", HomePath: "/usr/home", Pwd: "/usr/location/whatever", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "usr > .. > man", HomePath: "/usr/home", Pwd: "/usr/location/whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "~ > .. > man", HomePath: "/usr/home", Pwd: "/usr/home/whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "~ > projects", HomePath: "/usr/home", Pwd: "/usr/home/projects", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "C:", HomePath: homeBillWindows, Pwd: "C:", PathSeparator: "\\", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "/", HomePath: homeBillWindows, Pwd: "/", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: AgnosterShort, Expected: "foo", HomePath: homeBillWindows, Pwd: "/foo", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
|
||||
{Style: AgnosterShort, Expected: "usr > .. > bar > man", HomePath: "/usr/home", Pwd: "/usr/foo/bar/man", PathSeperator: "/", FolderSeparatorIcon: " > ", MaxDepth: 2},
|
||||
{Style: AgnosterShort, Expected: "usr > foo > bar > man", HomePath: "/usr/home", Pwd: "/usr/foo/bar/man", PathSeperator: "/", FolderSeparatorIcon: " > ", MaxDepth: 3},
|
||||
{Style: AgnosterShort, Expected: "~ > .. > bar > man", HomePath: "/usr/home", Pwd: "/usr/home/foo/bar/man", PathSeperator: "/", FolderSeparatorIcon: " > ", MaxDepth: 2},
|
||||
{Style: AgnosterShort, Expected: "~ > foo > bar > man", HomePath: "/usr/home", Pwd: "/usr/home/foo/bar/man", PathSeperator: "/", FolderSeparatorIcon: " > ", MaxDepth: 3},
|
||||
{Style: AgnosterShort, Expected: "usr > .. > bar > man", HomePath: "/usr/home", Pwd: "/usr/foo/bar/man", PathSeparator: "/", FolderSeparatorIcon: " > ", MaxDepth: 2},
|
||||
{Style: AgnosterShort, Expected: "usr > foo > bar > man", HomePath: "/usr/home", Pwd: "/usr/foo/bar/man", PathSeparator: "/", FolderSeparatorIcon: " > ", MaxDepth: 3},
|
||||
{Style: AgnosterShort, Expected: "~ > .. > bar > man", HomePath: "/usr/home", Pwd: "/usr/home/foo/bar/man", PathSeparator: "/", FolderSeparatorIcon: " > ", MaxDepth: 2},
|
||||
{Style: AgnosterShort, Expected: "~ > foo > bar > man", HomePath: "/usr/home", Pwd: "/usr/home/foo/bar/man", PathSeparator: "/", FolderSeparatorIcon: " > ", MaxDepth: 3},
|
||||
|
||||
{
|
||||
Style: AgnosterShort,
|
||||
Expected: "C: > .. > bar > man",
|
||||
HomePath: homeBillWindows,
|
||||
Pwd: "C:\\usr\\foo\\bar\\man",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
FolderSeparatorIcon: " > ",
|
||||
MaxDepth: 2,
|
||||
},
|
||||
|
@ -198,7 +198,7 @@ func TestAgnosterPathStyles(t *testing.T) {
|
|||
Expected: "C: > .. > foo > bar > man",
|
||||
HomePath: homeBillWindows,
|
||||
Pwd: "C:\\usr\\foo\\bar\\man",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
FolderSeparatorIcon: " > ",
|
||||
MaxDepth: 3,
|
||||
},
|
||||
|
@ -207,7 +207,7 @@ func TestAgnosterPathStyles(t *testing.T) {
|
|||
Expected: "~ > .. > bar > man",
|
||||
HomePath: homeBillWindows,
|
||||
Pwd: "C:\\Users\\Bill\\foo\\bar\\man",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
FolderSeparatorIcon: " > ",
|
||||
MaxDepth: 2,
|
||||
},
|
||||
|
@ -216,36 +216,36 @@ func TestAgnosterPathStyles(t *testing.T) {
|
|||
Expected: "~ > foo > bar > man",
|
||||
HomePath: homeBillWindows,
|
||||
Pwd: "C:\\Users\\Bill\\foo\\bar\\man",
|
||||
PathSeperator: "\\",
|
||||
PathSeparator: "\\",
|
||||
FolderSeparatorIcon: " > ",
|
||||
MaxDepth: 3,
|
||||
},
|
||||
|
||||
{Style: AgnosterFull, Expected: "PSDRIVE: | src", HomePath: homeBillWindows, Pwd: "/foo", Pswd: "PSDRIVE:/src", PathSeperator: "/", FolderSeparatorIcon: " | "},
|
||||
{Style: AgnosterShort, Expected: "PSDRIVE: | .. | init", HomePath: homeBillWindows, Pwd: "/foo", Pswd: "PSDRIVE:/src/init", PathSeperator: "/", FolderSeparatorIcon: " | "},
|
||||
{Style: AgnosterFull, Expected: "PSDRIVE: | src", HomePath: homeBillWindows, Pwd: "/foo", Pswd: "PSDRIVE:/src", PathSeparator: "/", FolderSeparatorIcon: " | "},
|
||||
{Style: AgnosterShort, Expected: "PSDRIVE: | .. | init", HomePath: homeBillWindows, Pwd: "/foo", Pswd: "PSDRIVE:/src/init", PathSeparator: "/", FolderSeparatorIcon: " | "},
|
||||
|
||||
{Style: Mixed, Expected: "~ > .. > man", HomePath: "/usr/home", Pwd: "/usr/home/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Mixed, Expected: "~ > ab > .. > man", HomePath: "/usr/home", Pwd: "/usr/home/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Mixed, Expected: "~ > .. > man", HomePath: "/usr/home", Pwd: "/usr/home/whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Mixed, Expected: "~ > ab > .. > man", HomePath: "/usr/home", Pwd: "/usr/home/ab/whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
|
||||
{Style: Letter, Expected: "~ > a > w > man", HomePath: "/usr/home", Pwd: "/usr/home/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/burp/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > a > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > a > ._w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/._whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .ä > ū > .w > man", HomePath: "/usr/home", Pwd: "/usr/.äufbau/ūmgebung/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > 1 > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/12345/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > 1 > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/12345abc/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > __p > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/__pycache__/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "➼ > .w > man", HomePath: "/usr/home", Pwd: "➼/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "➼ s > .w > man", HomePath: "/usr/home", Pwd: "➼ something/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "~ > a > w > man", HomePath: "/usr/home", Pwd: "/usr/home/ab/whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/burp/ab/whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > a > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/.whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > a > ._w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/._whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .ä > ū > .w > man", HomePath: "/usr/home", Pwd: "/usr/.äufbau/ūmgebung/.whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > 1 > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/12345/.whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > 1 > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/12345abc/.whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "u > .b > __p > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/__pycache__/.whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "➼ > .w > man", HomePath: "/usr/home", Pwd: "➼/.whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Letter, Expected: "➼ s > .w > man", HomePath: "/usr/home", Pwd: "➼ something/.whatever/man", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
|
||||
{Style: Unique, Expected: "~ > a > ab > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/abc/abcd", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Unique, Expected: "~ > a > .a > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/.abc/abcd", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Unique, Expected: "~ > a > ab > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/ab/abcd", PathSeperator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Unique, Expected: "~ > a > ab > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/abc/abcd", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Unique, Expected: "~ > a > .a > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/.abc/abcd", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
{Style: Unique, Expected: "~ > a > ab > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/ab/abcd", PathSeparator: "/", FolderSeparatorIcon: " > "},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return(tc.PathSeperator)
|
||||
env.On("PathSeparator").Return(tc.PathSeparator)
|
||||
env.On("Home").Return(tc.HomePath)
|
||||
env.On("Pwd").Return(tc.Pwd)
|
||||
env.On("GOOS").Return(tc.GOOS)
|
||||
|
@ -366,7 +366,7 @@ func TestGetFullPath(t *testing.T) {
|
|||
if len(tc.PathSeparator) == 0 {
|
||||
tc.PathSeparator = "/"
|
||||
}
|
||||
env.On("PathSeperator").Return(tc.PathSeparator)
|
||||
env.On("PathSeparator").Return(tc.PathSeparator)
|
||||
env.On("Home").Return("/usr/home")
|
||||
env.On("Pwd").Return(tc.Pwd)
|
||||
env.On("GOOS").Return(tc.GOOS)
|
||||
|
@ -417,7 +417,7 @@ func TestGetFullPathCustomMappedLocations(t *testing.T) {
|
|||
|
||||
for _, tc := range cases {
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return("/")
|
||||
env.On("PathSeparator").Return("/")
|
||||
env.On("Home").Return("/usr/home")
|
||||
env.On("Pwd").Return(tc.Pwd)
|
||||
env.On("GOOS").Return("")
|
||||
|
@ -468,7 +468,7 @@ func TestNormalizePath(t *testing.T) {
|
|||
func TestGetFolderPathCustomMappedLocations(t *testing.T) {
|
||||
pwd := "/a/b/c/d"
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return("/")
|
||||
env.On("PathSeparator").Return("/")
|
||||
env.On("Home").Return("/usr/home")
|
||||
env.On("Pwd").Return(pwd)
|
||||
env.On("GOOS").Return("")
|
||||
|
@ -516,7 +516,7 @@ func TestAgnosterPath(t *testing.T) { // nolint:dupl
|
|||
for _, tc := range cases {
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("Home").Return(tc.Home)
|
||||
env.On("PathSeperator").Return(tc.PathSeparator)
|
||||
env.On("PathSeparator").Return(tc.PathSeparator)
|
||||
env.On("Pwd").Return(tc.PWD)
|
||||
env.On("GOOS").Return("")
|
||||
args := &environment.Args{
|
||||
|
@ -564,7 +564,7 @@ func TestAgnosterLeftPath(t *testing.T) { // nolint:dupl
|
|||
for _, tc := range cases {
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("Home").Return(tc.Home)
|
||||
env.On("PathSeperator").Return(tc.PathSeparator)
|
||||
env.On("PathSeparator").Return(tc.PathSeparator)
|
||||
env.On("Pwd").Return(tc.PWD)
|
||||
env.On("GOOS").Return("")
|
||||
args := &environment.Args{
|
||||
|
@ -611,7 +611,7 @@ func TestGetPwd(t *testing.T) {
|
|||
|
||||
for _, tc := range cases {
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return("/")
|
||||
env.On("PathSeparator").Return("/")
|
||||
env.On("Home").Return("/usr/home")
|
||||
env.On("Pwd").Return(tc.Pwd)
|
||||
env.On("GOOS").Return("")
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestPythonTemplate(t *testing.T) {
|
|||
env.On("Getenv", "CONDA_ENV_PATH").Return(tc.VirtualEnvName)
|
||||
env.On("Getenv", "CONDA_DEFAULT_ENV").Return(tc.VirtualEnvName)
|
||||
env.On("Getenv", "PYENV_VERSION").Return(tc.VirtualEnvName)
|
||||
env.On("PathSeperator").Return("")
|
||||
env.On("PathSeparator").Return("")
|
||||
env.On("Pwd").Return("/usr/home/project")
|
||||
env.On("Home").Return("/usr/home")
|
||||
props := properties.Map{
|
||||
|
@ -80,7 +80,7 @@ func TestPythonPythonInContext(t *testing.T) {
|
|||
|
||||
for _, tc := range cases {
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return("")
|
||||
env.On("PathSeparator").Return("")
|
||||
env.On("Getenv", "VIRTUAL_ENV").Return(tc.VirtualEnvName)
|
||||
env.On("Getenv", "CONDA_ENV_PATH").Return("")
|
||||
env.On("Getenv", "CONDA_DEFAULT_ENV").Return("")
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestTextSegment(t *testing.T) {
|
|||
|
||||
for _, tc := range cases {
|
||||
env := new(mock.MockedEnvironment)
|
||||
env.On("PathSeperator").Return("/")
|
||||
env.On("PathSeparator").Return("/")
|
||||
env.On("TemplateCache").Return(&environment.TemplateCache{
|
||||
UserName: "Posh",
|
||||
Env: map[string]string{
|
||||
|
|
Loading…
Reference in a new issue