2018-03-08 14:45:53 +01:00
|
|
|
package projects
|
|
|
|
|
|
|
|
import (
|
2018-03-08 15:15:45 +01:00
|
|
|
"runtime"
|
2021-10-13 20:51:35 +02:00
|
|
|
"testing"
|
2018-03-08 14:45:53 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestIsValidInventoryPath(t *testing.T) {
|
|
|
|
if !IsValidInventoryPath("inventories/test") {
|
|
|
|
t.Fatal(" a path below the cwd should be valid")
|
|
|
|
}
|
|
|
|
|
|
|
|
if !IsValidInventoryPath("inventories/test/../prod") {
|
|
|
|
t.Fatal(" a path below the cwd should be valid")
|
|
|
|
}
|
|
|
|
|
|
|
|
if IsValidInventoryPath("/test/../../../inventory") {
|
|
|
|
t.Fatal(" a path out of the cwd should be invalid")
|
|
|
|
}
|
|
|
|
|
|
|
|
if IsValidInventoryPath("/test/inventory") {
|
|
|
|
t.Fatal(" a path out of the cwd should be invalid")
|
|
|
|
}
|
|
|
|
|
2018-03-08 15:15:45 +01:00
|
|
|
if runtime.GOOS == "windows" && IsValidInventoryPath("c:\\test\\inventory") {
|
2018-03-08 14:45:53 +01:00
|
|
|
t.Fatal(" a path out of the cwd should be invalid")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|