(t *testing.T)
| 596 | } |
| 597 | |
| 598 | func TestNewClientFromInvalidConfig(t *testing.T) { |
| 599 | newClientInvalidConfig := []struct { |
| 600 | clientConfig HTTPClientConfig |
| 601 | errorMsg string |
| 602 | }{ |
| 603 | { |
| 604 | clientConfig: HTTPClientConfig{ |
| 605 | TLSConfig: TLSConfig{ |
| 606 | CAFile: MissingCA, |
| 607 | InsecureSkipVerify: true, |
| 608 | }, |
| 609 | }, |
| 610 | errorMsg: "unable to read CA cert: unable to read file " + MissingCA, |
| 611 | }, |
| 612 | { |
| 613 | clientConfig: HTTPClientConfig{ |
| 614 | TLSConfig: TLSConfig{ |
| 615 | CAFile: InvalidCA, |
| 616 | InsecureSkipVerify: true, |
| 617 | }, |
| 618 | }, |
| 619 | errorMsg: "unable to use specified CA cert file " + InvalidCA, |
| 620 | }, |
| 621 | } |
| 622 | |
| 623 | for _, invalidConfig := range newClientInvalidConfig { |
| 624 | client, err := NewClientFromConfig(invalidConfig.clientConfig, "test") |
| 625 | if client != nil { |
| 626 | t.Errorf("A client instance was returned instead of nil using this config: %+v", invalidConfig.clientConfig) |
| 627 | } |
| 628 | if err == nil { |
| 629 | t.Errorf("No error was returned using this config: %+v", invalidConfig.clientConfig) |
| 630 | } |
| 631 | if !strings.Contains(err.Error(), invalidConfig.errorMsg) { |
| 632 | t.Errorf("Expected error %q does not contain %q", err.Error(), invalidConfig.errorMsg) |
| 633 | } |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | func TestCustomDialContextFunc(t *testing.T) { |
| 638 | dialFn := func(_ context.Context, _, _ string) (net.Conn, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…