pkg/system: CheckSystemDriveAndRemoveDriveLetter: fix error format
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ad371893f2
commit
c4872b4519
2 changed files with 5 additions and 5 deletions
|
@ -10,13 +10,13 @@ import (
|
|||
// of CheckSystemDriveAndRemoveDriveLetter
|
||||
func checkSystemDriveAndRemoveDriveLetter(path string) (string, error) {
|
||||
if len(path) == 2 && string(path[1]) == ":" {
|
||||
return "", fmt.Errorf("No relative path specified in %q", path)
|
||||
return "", fmt.Errorf("no relative path specified in %q", path)
|
||||
}
|
||||
if !filepath.IsAbs(path) || len(path) < 2 {
|
||||
return filepath.FromSlash(path), nil
|
||||
}
|
||||
if string(path[1]) == ":" && !strings.EqualFold(string(path[0]), "c") {
|
||||
return "", fmt.Errorf("The specified path is not on the system drive (C:)")
|
||||
return "", fmt.Errorf("the specified path is not on the system drive (C:)")
|
||||
}
|
||||
return filepath.FromSlash(path[2:]), nil
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) {
|
||||
// Fails if not C drive.
|
||||
_, err := CheckSystemDriveAndRemoveDriveLetter(`d:\`)
|
||||
if err == nil || err.Error() != "The specified path is not on the system drive (C:)" {
|
||||
if err == nil || err.Error() != "the specified path is not on the system drive (C:)" {
|
||||
t.Fatalf("Expected error for d:")
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) {
|
|||
if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:`); err == nil {
|
||||
t.Fatalf("c: should fail")
|
||||
}
|
||||
if err.Error() != `No relative path specified in "c:"` {
|
||||
if err.Error() != `no relative path specified in "c:"` {
|
||||
t.Fatalf(path, err)
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) {
|
|||
if path, err = CheckSystemDriveAndRemoveDriveLetter(`d:`); err == nil {
|
||||
t.Fatalf("c: should fail")
|
||||
}
|
||||
if err.Error() != `No relative path specified in "d:"` {
|
||||
if err.Error() != `no relative path specified in "d:"` {
|
||||
t.Fatalf(path, err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue