From 852334e4352a0f75381b86d1cdf571427913e66c Mon Sep 17 00:00:00 2001 From: quobix Date: Mon, 15 Jan 2024 12:22:21 -0500 Subject: [PATCH] Fixing unix test Signed-off-by: quobix --- utils/windows_drive_test.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/utils/windows_drive_test.go b/utils/windows_drive_test.go index 2e1eebd..ed4e93a 100644 --- a/utils/windows_drive_test.go +++ b/utils/windows_drive_test.go @@ -1,6 +1,7 @@ package utils import ( + "os" "runtime" "testing" ) @@ -22,15 +23,22 @@ func TestReplaceWindowsDriveWithLinuxPath(t *testing.T) { } func TestCheckPathOverlap(t *testing.T) { - pathA := `C:\Users\pb33f` - pathB := `pb33f\files\thing.yaml` - expected := `C:\Users\pb33f\files\thing.yaml` - if runtime.GOOS != "windows" { - expected = `/Users/pb33f/files/thing.yaml` - } - result := CheckPathOverlap(pathA, pathB, `\`) - if result != expected { - t.Errorf("Expected %s, got %s", expected, result) + if runtime.GOOS == "windows" { + pathA := `C:\Users\pb33f` + pathB := `pb33f\files\thing.yaml` + expected := `C:\Users\pb33f\files\thing.yaml` + result := CheckPathOverlap(pathA, pathB, string(os.PathSeparator)) + 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) + } } }