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

Function TestHTTPProvider_ContextCanceled

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

Source from the content-addressed store, hash-verified

111}
112
113func TestHTTPProvider_ContextCanceled(t *testing.T) {
114 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
115 select {
116 case <-time.After(10 * time.Second):
117 case <-r.Context().Done():
118 }
119 }))
120 defer srv.Close()
121
122 p, _ := newTestHTTPProvider(t, srv.URL+"/config.yaml", &http.Client{})
123
124 ctx, cancel := context.WithCancel(context.Background())
125 cancel()
126
127 _, err := p.Read(ctx)
128 require.Error(t, err)
129}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected