MCPcopy
hub / github.com/grafana/dskit / TestHTTPProvider_Timeout

Function TestHTTPProvider_Timeout

runtimeconfig/provider_test.go:96–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func TestHTTPProvider_Timeout(t *testing.T) {
97 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
98 select {
99 case <-time.After(10 * time.Second):
100 case <-r.Context().Done():
101 }
102 }))
103 defer srv.Close()
104
105 p, _ := newTestHTTPProvider(t, srv.URL+"/config.yaml", &http.Client{Timeout: 50 * time.Millisecond})
106
107 _, err := p.Read(context.Background())
108 require.Error(t, err)
109
110 assert.Equal(t, 1, testutil.CollectAndCount(p.requestDuration))
111}
112
113func TestHTTPProvider_ContextCanceled(t *testing.T) {
114 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 8

newTestHTTPProviderFunction · 0.85
AfterMethod · 0.65
DoneMethod · 0.65
CloseMethod · 0.65
ReadMethod · 0.65
ContextMethod · 0.45
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected