MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestAPIConfig

Function TestAPIConfig

pkg/cortex/modules_test.go:27–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func TestAPIConfig(t *testing.T) {
28 actualCfg := newDefaultConfig()
29
30 cortex := &Cortex{
31 Server: &server.Server{},
32 }
33
34 for _, tc := range []struct {
35 name string
36 path string
37 actualCfg func(*Config)
38 expectedStatusCode int
39 expectedBody func(*testing.T, string)
40 }{
41 {
42 name: "running with default config",
43 path: "/config",
44 expectedStatusCode: 200,
45 },
46 {
47 name: "defaults with default config",
48 path: "/config?mode=defaults",
49 expectedStatusCode: 200,
50 },
51 {
52 name: "diff with default config",
53 path: "/config?mode=diff",
54 expectedStatusCode: 200,
55 expectedBody: func(t *testing.T, body string) {
56 assert.Equal(t, "{}\n", body)
57 },
58 },
59 {
60 name: "running with changed target config",
61 path: "/config",
62 actualCfg: changeTargetConfig,
63 expectedStatusCode: 200,
64 expectedBody: func(t *testing.T, body string) {
65 assert.Contains(t, body, "target: all,ruler\n")
66 },
67 },
68 {
69 name: "defaults with changed target config",
70 path: "/config?mode=defaults",
71 actualCfg: changeTargetConfig,
72 expectedStatusCode: 200,
73 expectedBody: func(t *testing.T, body string) {
74 assert.Contains(t, body, "target: all\n")
75 },
76 },
77 {
78 name: "diff with changed target config",
79 path: "/config?mode=diff",
80 actualCfg: changeTargetConfig,
81 expectedStatusCode: 200,
82 expectedBody: func(t *testing.T, body string) {
83 assert.Equal(t, "target: all,ruler\n", body)
84 },

Callers

nothing calls this directly

Calls 6

initAPIMethod · 0.95
newDefaultConfigFunction · 0.85
EqualMethod · 0.65
RunMethod · 0.65
StringMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected