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

Function TestNeedsServerInfo

cli/command/system/info_test.go:485–534  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

483}
484
485func TestNeedsServerInfo(t *testing.T) {
486 tests := []struct {
487 doc string
488 template string
489 expected bool
490 }{
491 {
492 doc: "no template",
493 template: "",
494 expected: true,
495 },
496 {
497 doc: "JSON",
498 template: "json",
499 expected: true,
500 },
501 {
502 doc: "JSON (all fields)",
503 template: "{{json .}}",
504 expected: true,
505 },
506 {
507 doc: "JSON (Server ID)",
508 template: "{{json .ID}}",
509 expected: true,
510 },
511 {
512 doc: "ClientInfo",
513 template: "{{json .ClientInfo}}",
514 expected: false,
515 },
516 {
517 doc: "JSON ClientInfo",
518 template: "{{json .ClientInfo}}",
519 expected: false,
520 },
521 {
522 doc: "JSON (Active context)",
523 template: "{{json .ClientInfo.Context}}",
524 expected: false,
525 },
526 }
527
528 inf := dockerInfo{ClientInfo: &clientInfo{}}
529 for _, tc := range tests {
530 t.Run(tc.doc, func(t *testing.T) {
531 assert.Equal(t, needsServerInfo(tc.template, inf), tc.expected)
532 })
533 }
534}

Callers

nothing calls this directly

Calls 1

needsServerInfoFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…