(t *testing.T)
| 214 | } |
| 215 | |
| 216 | func 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 | |
| 261 | func TestCopyFromContainerReportsFileSize(t *testing.T) { |
| 262 | // The file content is "hello" (5 bytes), but the TAR archive wrapping |
nothing calls this directly
no test coverage detected
searching dependent graphs…