Fixing unix test

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2024-01-15 12:22:21 -05:00
parent 1f21f1432d
commit 852334e435

View File

@@ -1,6 +1,7 @@
package utils package utils
import ( import (
"os"
"runtime" "runtime"
"testing" "testing"
) )
@@ -22,15 +23,22 @@ func TestReplaceWindowsDriveWithLinuxPath(t *testing.T) {
} }
func TestCheckPathOverlap(t *testing.T) { func TestCheckPathOverlap(t *testing.T) {
pathA := `C:\Users\pb33f` if runtime.GOOS == "windows" {
pathB := `pb33f\files\thing.yaml` pathA := `C:\Users\pb33f`
expected := `C:\Users\pb33f\files\thing.yaml` pathB := `pb33f\files\thing.yaml`
if runtime.GOOS != "windows" { expected := `C:\Users\pb33f\files\thing.yaml`
expected = `/Users/pb33f/files/thing.yaml` result := CheckPathOverlap(pathA, pathB, string(os.PathSeparator))
} if result != expected {
result := CheckPathOverlap(pathA, pathB, `\`) t.Errorf("Expected %s, got %s", expected, result)
if result != expected { }
t.Errorf("Expected %s, got %s", expected, result) } else {
pathA := `/Users/pb33f`
pathB := `pb33f/files/thing.yaml`
expected := `/Users/pb33f/files/thing.yaml`
result := CheckPathOverlap(pathA, pathB, string(os.PathSeparator))
if result != expected {
t.Errorf("Expected %s, got %s", expected, result)
}
} }
} }