(t *testing.T)
| 312 | } |
| 313 | |
| 314 | func TestImageContextWriteWithNoImage(t *testing.T) { |
| 315 | out := bytes.NewBufferString("") |
| 316 | images := []image.Summary{} |
| 317 | |
| 318 | cases := []struct { |
| 319 | context ImageContext |
| 320 | expected string |
| 321 | }{ |
| 322 | { |
| 323 | ImageContext{ |
| 324 | Context: Context{ |
| 325 | Format: NewImageFormat("{{.Repository}}", false, false), |
| 326 | Output: out, |
| 327 | }, |
| 328 | }, |
| 329 | "", |
| 330 | }, |
| 331 | { |
| 332 | ImageContext{ |
| 333 | Context: Context{ |
| 334 | Format: NewImageFormat("table {{.Repository}}", false, false), |
| 335 | Output: out, |
| 336 | }, |
| 337 | }, |
| 338 | "REPOSITORY\n", |
| 339 | }, |
| 340 | { |
| 341 | ImageContext{ |
| 342 | Context: Context{ |
| 343 | Format: NewImageFormat("{{.Repository}}", false, true), |
| 344 | Output: out, |
| 345 | }, |
| 346 | }, |
| 347 | "", |
| 348 | }, |
| 349 | { |
| 350 | ImageContext{ |
| 351 | Context: Context{ |
| 352 | Format: NewImageFormat("table {{.Repository}}", false, true), |
| 353 | Output: out, |
| 354 | }, |
| 355 | }, |
| 356 | "REPOSITORY DIGEST\n", |
| 357 | }, |
| 358 | } |
| 359 | |
| 360 | for _, tc := range cases { |
| 361 | t.Run(string(tc.context.Format), func(t *testing.T) { |
| 362 | err := ImageWrite(tc.context, images) |
| 363 | assert.NilError(t, err) |
| 364 | assert.Equal(t, out.String(), tc.expected) |
| 365 | // Clean buffer |
| 366 | out.Reset() |
| 367 | }) |
| 368 | } |
| 369 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…