MCPcopy Index your code
hub / github.com/docker/cli / TestSplitCpArg

Function TestSplitCpArg

cli/command/container/cp_test.go:152–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestSplitCpArg(t *testing.T) {
153 testcases := []struct {
154 doc string
155 path string
156 os string
157 expectedContainer string
158 expectedPath string
159 }{
160 {
161 doc: "absolute path with colon",
162 os: "unix",
163 path: "/abs/path:withcolon",
164 expectedPath: "/abs/path:withcolon",
165 },
166 {
167 doc: "relative path with colon",
168 path: "./relative:path",
169 expectedPath: "./relative:path",
170 },
171 {
172 doc: "absolute path with drive",
173 os: "windows",
174 path: `d:\abs\path`,
175 expectedPath: `d:\abs\path`,
176 },
177 {
178 doc: "no separator",
179 path: "relative/path",
180 expectedPath: "relative/path",
181 },
182 {
183 doc: "with separator",
184 path: "container:/opt/foo",
185 expectedPath: "/opt/foo",
186 expectedContainer: "container",
187 },
188 }
189 for _, tc := range testcases {
190 t.Run(tc.doc, func(t *testing.T) {
191 if tc.os == "windows" && runtime.GOOS != "windows" {
192 t.Skip("skipping windows test on non-windows platform")
193 }
194 if tc.os == "unix" && runtime.GOOS == "windows" {
195 t.Skip("skipping unix test on windows")
196 }
197
198 ctr, path := splitCpArg(tc.path)
199 assert.Check(t, is.Equal(tc.expectedContainer, ctr))
200 assert.Check(t, is.Equal(tc.expectedPath, path))
201 })
202 }
203}
204
205func TestRunCopyFromContainerToFilesystemIrregularDestination(t *testing.T) {
206 cli := test.NewFakeCli(nil)

Callers

nothing calls this directly

Calls 1

splitCpArgFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…