(t *testing.T)
| 483 | } |
| 484 | |
| 485 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…