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

Function TestHTTPProvider_ServerError

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

Source from the content-addressed store, hash-verified

58}
59
60func TestHTTPProvider_ServerError(t *testing.T) {
61 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
62 w.WriteHeader(http.StatusInternalServerError)
63 }))
64 defer srv.Close()
65
66 p, _ := newTestHTTPProvider(t, srv.URL+"/config.yaml", &http.Client{})
67
68 _, err := p.Read(context.Background())
69 require.Error(t, err)
70 assert.Contains(t, err.Error(), "HTTP 500")
71
72 var httpErr *httpError
73 require.ErrorAs(t, err, &httpErr)
74 assert.Equal(t, 500, httpErr.statusCode)
75
76 assert.Equal(t, 1, testutil.CollectAndCount(p.requestDuration))
77}
78
79func TestHTTPProvider_NonOKStatus(t *testing.T) {
80 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {

Callers

nothing calls this directly

Calls 6

newTestHTTPProviderFunction · 0.85
CloseMethod · 0.65
ReadMethod · 0.65
WriteHeaderMethod · 0.45
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected