...
1
2
3 package main
4
5 import (
6 "os"
7 "testing"
8
9 "github.com/Microsoft/hcsshim/internal/runhcs"
10 )
11
12 func Test_AbsPathOrEmpty(t *testing.T) {
13 wd, err := os.Getwd()
14 if err != nil {
15 t.Fatalf("failed to get test wd: %v", err)
16 }
17
18 tests := []string{
19 "",
20 runhcs.SafePipePrefix + "test",
21 runhcs.SafePipePrefix + "test with spaces",
22 "test",
23 "C:\\test..\\test",
24 }
25 expected := []string{
26 "",
27 runhcs.SafePipePrefix + "test",
28 runhcs.SafePipePrefix + "test%20with%20spaces",
29 wd + "\\test",
30 "C:\\test..\\test",
31 }
32 for i, test := range tests {
33 actual, err := absPathOrEmpty(test)
34 if err != nil {
35 t.Fatalf("absPathOrEmpty: error '%v'", err)
36 }
37 if actual != expected[i] {
38 t.Fatalf("absPathOrEmpty: actual '%s' != '%s'", actual, expected[i])
39 }
40 }
41 }
42
View as plain text