(t *testing.T)
| 555 | } |
| 556 | |
| 557 | func TestNewClientFromInvalidConfig(t *testing.T) { |
| 558 | newClientInvalidConfig := []struct { |
| 559 | clientConfig HTTPClientConfig |
| 560 | errorMsg string |
| 561 | }{ |
| 562 | { |
| 563 | clientConfig: HTTPClientConfig{ |
| 564 | TLSConfig: TLSConfig{ |
| 565 | CAFile: MissingCA, |
| 566 | InsecureSkipVerify: true, |
| 567 | }, |
| 568 | }, |
| 569 | errorMsg: fmt.Sprintf("unable to load specified CA cert %s:", MissingCA), |
| 570 | }, |
| 571 | { |
| 572 | clientConfig: HTTPClientConfig{ |
| 573 | TLSConfig: TLSConfig{ |
| 574 | CAFile: InvalidCA, |
| 575 | InsecureSkipVerify: true, |
| 576 | }, |
| 577 | }, |
| 578 | errorMsg: fmt.Sprintf("unable to use specified CA cert %s", InvalidCA), |
| 579 | }, |
| 580 | } |
| 581 | |
| 582 | for _, invalidConfig := range newClientInvalidConfig { |
| 583 | client, err := NewClientFromConfig(invalidConfig.clientConfig, "test") |
| 584 | if client != nil { |
| 585 | t.Errorf("A client instance was returned instead of nil using this config: %+v", invalidConfig.clientConfig) |
| 586 | } |
| 587 | if err == nil { |
| 588 | t.Errorf("No error was returned using this config: %+v", invalidConfig.clientConfig) |
| 589 | } |
| 590 | if !strings.Contains(err.Error(), invalidConfig.errorMsg) { |
| 591 | t.Errorf("Expected error %q does not contain %q", err.Error(), invalidConfig.errorMsg) |
| 592 | } |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | func TestCustomDialContextFunc(t *testing.T) { |
| 597 | dialFn := func(_ context.Context, _, _ string) (net.Conn, error) { |
nothing calls this directly
no test coverage detected