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

Function TestHTTPProvider_NonOKStatus

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

Source from the content-addressed store, hash-verified

77}
78
79func TestHTTPProvider_NonOKStatus(t *testing.T) {
80 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
81 w.WriteHeader(http.StatusForbidden)
82 }))
83 defer srv.Close()
84
85 p, _ := newTestHTTPProvider(t, srv.URL+"/config.yaml", &http.Client{})
86
87 _, err := p.Read(context.Background())
88 require.Error(t, err)
89 assert.Contains(t, err.Error(), "HTTP 403")
90
91 var httpErr *httpError
92 require.ErrorAs(t, err, &httpErr)
93 assert.Equal(t, 403, httpErr.statusCode)
94}
95
96func TestHTTPProvider_Timeout(t *testing.T) {
97 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *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