MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestConfigOverrideHandler

Function TestConfigOverrideHandler

pkg/api/handlers_test.go:174–198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

172}
173
174func TestConfigOverrideHandler(t *testing.T) {
175 cfg := &Config{
176 CustomConfigHandler: func(_ any, _ any) http.HandlerFunc {
177 return func(w http.ResponseWriter, r *http.Request) {
178 _, err := w.Write([]byte("config"))
179 assert.NoError(t, err)
180 }
181 },
182 }
183
184 req := httptest.NewRequest("GET", "http://test.com/config", nil)
185 w := httptest.NewRecorder()
186
187 h := cfg.configHandler(
188 struct{ name string }{name: "actual"},
189 struct{ name string }{name: "default"},
190 )
191 h(w, req)
192 resp := w.Result()
193 assert.Equal(t, 200, resp.StatusCode)
194
195 body, err := io.ReadAll(resp.Body)
196 assert.NoError(t, err)
197 assert.Equal(t, []byte("config"), body)
198}
199
200func TestBuildInfoAPI(t *testing.T) {
201 type buildInfo struct {

Callers

nothing calls this directly

Calls 3

configHandlerMethod · 0.95
EqualMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected