@@ -5,25 +5,31 @@ package dockerfile
5
5
import "testing"
6
6
7
7
func TestNormaliseWorkdir (t * testing.T ) {
8
- tests := []struct { current , requested , expected , etext string }{
9
- {`` , `` , `` , `cannot normalise nothing` },
10
- {`` , `C:` , `` , `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'` },
11
- {`` , `C:.` , `` , `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'` },
12
- {`c:` , `\a` , `` , `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'` },
13
- {`c:.` , `\a` , `` , `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'` },
14
- {`` , `a` , `C:\a` , `` },
15
- {`` , `c:\foo` , `C:\foo` , `` },
16
- {`` , `c:\\foo` , `C:\foo` , `` },
17
- {`` , `\foo` , `C:\foo` , `` },
18
- {`` , `\\foo` , `C:\foo` , `` },
19
- {`` , `/foo` , `C:\foo` , `` },
20
- {`` , `C:/foo` , `C:\foo` , `` },
21
- {`C:\foo` , `bar` , `C:\foo\bar` , `` },
22
- {`C:\foo` , `/bar` , `C:\bar` , `` },
23
- {`C:\foo` , `\bar` , `C:\bar` , `` },
8
+ tests := []struct { platform , current , requested , expected , etext string }{
9
+ {"windows" , `` , `` , `` , `cannot normalise nothing` },
10
+ {"windows" , `` , `C:` , `` , `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'` },
11
+ {"windows" , `` , `C:.` , `` , `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'` },
12
+ {"windows" , `c:` , `\a` , `` , `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'` },
13
+ {"windows" , `c:.` , `\a` , `` , `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'` },
14
+ {"windows" , `` , `a` , `C:\a` , `` },
15
+ {"windows" , `` , `c:\foo` , `C:\foo` , `` },
16
+ {"windows" , `` , `c:\\foo` , `C:\foo` , `` },
17
+ {"windows" , `` , `\foo` , `C:\foo` , `` },
18
+ {"windows" , `` , `\\foo` , `C:\foo` , `` },
19
+ {"windows" , `` , `/foo` , `C:\foo` , `` },
20
+ {"windows" , `` , `C:/foo` , `C:\foo` , `` },
21
+ {"windows" , `C:\foo` , `bar` , `C:\foo\bar` , `` },
22
+ {"windows" , `C:\foo` , `/bar` , `C:\bar` , `` },
23
+ {"windows" , `C:\foo` , `\bar` , `C:\bar` , `` },
24
+ {"linux" , `` , `` , `` , `cannot normalise nothing` },
25
+ {"linux" , `` , `foo` , `/foo` , `` },
26
+ {"linux" , `` , `/foo` , `/foo` , `` },
27
+ {"linux" , `/foo` , `bar` , `/foo/bar` , `` },
28
+ {"linux" , `/foo` , `/bar` , `/bar` , `` },
29
+ {"linux" , `\a` , `b\c` , `/a/b/c` , `` },
24
30
}
25
31
for _ , i := range tests {
26
- r , e := normaliseWorkdir (i .current , i .requested )
32
+ r , e := normaliseWorkdir (i .platform , i . current , i .requested )
27
33
28
34
if i .etext != "" && e == nil {
29
35
t .Fatalf ("TestNormaliseWorkingDir Expected error %s for '%s' '%s', got no error" , i .etext , i .current , i .requested )
0 commit comments