mirror of
https://github.com/rancher/plugins.git
synced 2025-07-08 20:53:53 +00:00
40 lines
765 B
Go
40 lines
765 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/Microsoft/hcsshim/internal/runhcs"
|
|
)
|
|
|
|
func Test_AbsPathOrEmpty(t *testing.T) {
|
|
wd, err := os.Getwd()
|
|
if err != nil {
|
|
t.Fatalf("failed to get test wd: %v", err)
|
|
}
|
|
|
|
tests := []string{
|
|
"",
|
|
runhcs.SafePipePrefix + "test",
|
|
runhcs.SafePipePrefix + "test with spaces",
|
|
"test",
|
|
"C:\\test..\\test",
|
|
}
|
|
expected := []string{
|
|
"",
|
|
runhcs.SafePipePrefix + "test",
|
|
runhcs.SafePipePrefix + "test%20with%20spaces",
|
|
wd + "\\test",
|
|
"C:\\test..\\test",
|
|
}
|
|
for i, test := range tests {
|
|
actual, err := absPathOrEmpty(test)
|
|
if err != nil {
|
|
t.Fatalf("absPathOrEmpty: error '%v'", err)
|
|
}
|
|
if actual != expected[i] {
|
|
t.Fatalf("absPathOrEmpty: actual '%s' != '%s'", actual, expected[i])
|
|
}
|
|
}
|
|
}
|