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

Function TestImageContextWriteWithNoImage

cli/command/formatter/image_test.go:314–369  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

312}
313
314func 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}

Callers

nothing calls this directly

Calls 3

NewImageFormatFunction · 0.85
ImageWriteFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…