mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-08 04:20:17 +00:00
@@ -1,6 +1,7 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -22,16 +23,23 @@ func TestReplaceWindowsDriveWithLinuxPath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckPathOverlap(t *testing.T) {
|
func TestCheckPathOverlap(t *testing.T) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
pathA := `C:\Users\pb33f`
|
pathA := `C:\Users\pb33f`
|
||||||
pathB := `pb33f\files\thing.yaml`
|
pathB := `pb33f\files\thing.yaml`
|
||||||
expected := `C:\Users\pb33f\files\thing.yaml`
|
expected := `C:\Users\pb33f\files\thing.yaml`
|
||||||
if runtime.GOOS != "windows" {
|
result := CheckPathOverlap(pathA, pathB, string(os.PathSeparator))
|
||||||
expected = `/Users/pb33f/files/thing.yaml`
|
|
||||||
}
|
|
||||||
result := CheckPathOverlap(pathA, pathB, `\`)
|
|
||||||
if result != expected {
|
if result != expected {
|
||||||
t.Errorf("Expected %s, got %s", expected, result)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckPathOverlap_VariationA(t *testing.T) {
|
func TestCheckPathOverlap_VariationA(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user