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

Function TestHTTPProvider_Success

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

Source from the content-addressed store, hash-verified

40}
41
42func TestHTTPProvider_Success(t *testing.T) {
43 body := "overrides:\n user1:\n limit1: 100\n"
44 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
45 assert.Equal(t, "dskit-runtimeconfig", r.Header.Get("User-Agent"))
46 _, _ = w.Write([]byte(body))
47 }))
48 defer srv.Close()
49
50 p, _ := newTestHTTPProvider(t, srv.URL+"/config.yaml", &http.Client{})
51
52 data, err := p.Read(context.Background())
53 require.NoError(t, err)
54 assert.Equal(t, body, string(data))
55 assert.Equal(t, srv.URL+"/config.yaml", p.Name())
56
57 assert.Equal(t, 1, testutil.CollectAndCount(p.requestDuration))
58}
59
60func TestHTTPProvider_ServerError(t *testing.T) {
61 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {

Callers

nothing calls this directly

Calls 7

newTestHTTPProviderFunction · 0.85
GetMethod · 0.65
CloseMethod · 0.65
ReadMethod · 0.65
NameMethod · 0.65
EqualMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected