github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/builder/dockerfile/internals_windows_test.go (about) 1 // +build windows 2 3 package dockerfile 4 5 import ( 6 "fmt" 7 "testing" 8 9 "github.com/docker/docker/internal/testutil" 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestNormalizeDest(t *testing.T) { 14 tests := []struct{ current, requested, expected, etext string }{ 15 {``, `D:\`, ``, `Windows does not support destinations not on the system drive (C:)`}, 16 {``, `e:/`, ``, `Windows does not support destinations not on the system drive (C:)`}, 17 {`invalid`, `./c1`, ``, `Current WorkingDir invalid is not platform consistent`}, 18 {`C:`, ``, ``, `Current WorkingDir C: is not platform consistent`}, 19 {`C`, ``, ``, `Current WorkingDir C is not platform consistent`}, 20 {`D:\`, `.`, ``, "Windows does not support relative paths when WORKDIR is not the system drive"}, 21 {``, `D`, `D`, ``}, 22 {``, `./a1`, `.\a1`, ``}, 23 {``, `.\b1`, `.\b1`, ``}, 24 {``, `/`, `\`, ``}, 25 {``, `\`, `\`, ``}, 26 {``, `c:/`, `\`, ``}, 27 {``, `c:\`, `\`, ``}, 28 {``, `.`, `.`, ``}, 29 {`C:\wdd`, `./a1`, `\wdd\a1`, ``}, 30 {`C:\wde`, `.\b1`, `\wde\b1`, ``}, 31 {`C:\wdf`, `/`, `\`, ``}, 32 {`C:\wdg`, `\`, `\`, ``}, 33 {`C:\wdh`, `c:/`, `\`, ``}, 34 {`C:\wdi`, `c:\`, `\`, ``}, 35 {`C:\wdj`, `.`, `\wdj`, ``}, 36 {`C:\wdk`, `foo/bar`, `\wdk\foo\bar`, ``}, 37 {`C:\wdl`, `foo\bar`, `\wdl\foo\bar`, ``}, 38 {`C:\wdm`, `foo/bar/`, `\wdm\foo\bar\`, ``}, 39 {`C:\wdn`, `foo\bar/`, `\wdn\foo\bar\`, ``}, 40 } 41 for _, testcase := range tests { 42 msg := fmt.Sprintf("Input: %s, %s", testcase.current, testcase.requested) 43 actual, err := normalizeDest(testcase.current, testcase.requested, "windows") 44 if testcase.etext == "" { 45 if !assert.NoError(t, err, msg) { 46 continue 47 } 48 assert.Equal(t, testcase.expected, actual, msg) 49 } else { 50 testutil.ErrorContains(t, err, testcase.etext) 51 } 52 } 53 }