(t *testing.T)
| 635 | } |
| 636 | |
| 637 | func TestCustomDialContextFunc(t *testing.T) { |
| 638 | dialFn := func(_ context.Context, _, _ string) (net.Conn, error) { |
| 639 | return nil, errors.New(ExpectedError) |
| 640 | } |
| 641 | |
| 642 | cfg := HTTPClientConfig{} |
| 643 | client, err := NewClientFromConfig(cfg, "test", WithDialContextFunc(dialFn)) |
| 644 | require.NoErrorf(t, err, "Can't create a client from this config: %+v", cfg) |
| 645 | |
| 646 | _, err = client.Get("http://localhost") |
| 647 | if err == nil || !strings.Contains(err.Error(), ExpectedError) { |
| 648 | t.Errorf("Expected error %q but got %q", ExpectedError, err) |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | func TestCustomIdleConnTimeout(t *testing.T) { |
| 653 | timeout := time.Second * 5 |
nothing calls this directly
no test coverage detected