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

Function TestMetadataHandler_Success

pkg/querier/metadata_handler_test.go:16–200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestMetadataHandler_Success(t *testing.T) {
17 t.Parallel()
18
19 d := &MockDistributor{}
20 d.On("MetricsMetadata", mock.Anything, mock.Anything).Return(
21 []scrape.MetricMetadata{
22 {MetricFamily: "alertmanager_dispatcher_aggregation_groups", Help: "Number of active aggregation groups", Type: "gauge", Unit: ""},
23 {MetricFamily: "go_threads", Help: "Number of OS threads created", Type: "gauge", Unit: ""},
24 {MetricFamily: "go_threads", Help: "Number of OS threads that were created", Type: "gauge", Unit: ""},
25 },
26 nil)
27
28 fullResponseJson := `
29 {
30 "status": "success",
31 "data": {
32 "alertmanager_dispatcher_aggregation_groups": [
33 {
34 "help": "Number of active aggregation groups",
35 "type": "gauge",
36 "unit": ""
37 }
38 ],
39 "go_threads": [
40 {
41 "help": "Number of OS threads created",
42 "type": "gauge",
43 "unit": ""
44 },
45 {
46 "help": "Number of OS threads that were created",
47 "type": "gauge",
48 "unit": ""
49 }
50 ]
51 }
52 }
53 `
54
55 emptyDataResponseJson := `
56 {
57 "status": "success",
58 "data": {}
59 }
60 `
61
62 tests := []struct {
63 description string
64 queryParams url.Values
65 expectedCode int
66 expectedJson string
67 }{
68 {
69 description: "no params",
70 queryParams: url.Values{},
71 expectedCode: http.StatusOK,
72 expectedJson: fullResponseJson,
73 },

Callers

nothing calls this directly

Calls 5

MetadataHandlerFunction · 0.85
RunMethod · 0.65
EncodeMethod · 0.65
EqualMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected