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

Function TestCopySummary

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

Source from the content-addressed store, hash-verified

214}
215
216func TestCopySummary(t *testing.T) {
217 tests := []struct {
218 name string
219 contentSize int64
220 transferredSize int64
221 dest string
222 wantContains string
223 wantNoContain string
224 }{
225 {
226 name: "different sizes shows both",
227 contentSize: 5,
228 transferredSize: 2048,
229 dest: "/dst",
230 wantContains: "(transferred",
231 },
232 {
233 name: "equal sizes shows single value",
234 contentSize: 100,
235 transferredSize: 100,
236 dest: "/dst",
237 wantNoContain: "(transferred",
238 },
239 {
240 name: "both zero",
241 contentSize: 0,
242 transferredSize: 0,
243 dest: "ctr:/dst",
244 wantContains: "Successfully copied 0B to ctr:/dst",
245 wantNoContain: "(transferred",
246 },
247 }
248 for _, tc := range tests {
249 t.Run(tc.name, func(t *testing.T) {
250 got := copySummary(tc.contentSize, tc.transferredSize, tc.dest)
251 if tc.wantContains != "" {
252 assert.Check(t, is.Contains(got, tc.wantContains))
253 }
254 if tc.wantNoContain != "" {
255 assert.Check(t, !strings.Contains(got, tc.wantNoContain), "unexpected substring %q in %q", tc.wantNoContain, got)
256 }
257 })
258 }
259}
260
261func TestCopyFromContainerReportsFileSize(t *testing.T) {
262 // The file content is "hello" (5 bytes), but the TAR archive wrapping

Callers

nothing calls this directly

Calls 2

copySummaryFunction · 0.85
ContainsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…