MCPcopy Create free account
hub / github.com/prometheus/common / TestCustomDialContextFunc

Function TestCustomDialContextFunc

config/http_config_test.go:637–650  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

635}
636
637func 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
652func TestCustomIdleConnTimeout(t *testing.T) {
653 timeout := time.Second * 5

Callers

nothing calls this directly

Calls 4

NewClientFromConfigFunction · 0.85
WithDialContextFuncFunction · 0.85
GetMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected