@@ -66,28 +66,33 @@ func TestHealthEndpoint(t *testing.T) {
6666 }
6767}
6868
69- func TestListMetrics (t * testing.T ) {
70- resp , err := mcpClient .CallTool (t , 1 , "list_metrics" , map [string ]any {
69+ func TestListMetricsReturnsKnownMetrics (t * testing.T ) {
70+ resp , err := mcpClient .CallTool (t , 2 , "list_metrics" , map [string ]any {
7171 "name_regex" : ".*" ,
7272 })
7373 if err != nil {
7474 t .Fatalf ("Failed to call list_metrics: %v" , err )
7575 }
7676
7777 if resp .Error != nil {
78- t .Errorf ("MCP error: %s" , resp .Error .Message )
78+ t .Fatalf ("MCP error: %s" , resp .Error .Message )
7979 }
8080
81- if resp . Result == nil {
82- t . Error ( "Expected result, got nil" )
83- }
81+ // Verify known metrics from kube-prometheus are present
82+ resultJSON , _ := json . Marshal ( resp . Result )
83+ resultStr := string ( resultJSON )
8484
85- t .Logf ("list_metrics returned successfully" )
85+ expectedMetrics := []string {"up" , "prometheus_build_info" }
86+ for _ , metric := range expectedMetrics {
87+ if ! strings .Contains (resultStr , metric ) {
88+ t .Errorf ("Expected metric %q not found in results" , metric )
89+ }
90+ }
8691}
8792
88- func TestListMetricsReturnsKnownMetrics (t * testing.T ) {
93+ func TestListMetricsReturnsKnownMetricsWithMatcher (t * testing.T ) {
8994 resp , err := mcpClient .CallTool (t , 2 , "list_metrics" , map [string ]any {
90- "name_regex" : ".*" ,
95+ "name_regex" : "prometheus .*" ,
9196 })
9297 if err != nil {
9398 t .Fatalf ("Failed to call list_metrics: %v" , err )
@@ -101,7 +106,7 @@ func TestListMetricsReturnsKnownMetrics(t *testing.T) {
101106 resultJSON , _ := json .Marshal (resp .Result )
102107 resultStr := string (resultJSON )
103108
104- expectedMetrics := []string {"up" , " prometheus_build_info" }
109+ expectedMetrics := []string {"prometheus_build_info" }
105110 for _ , metric := range expectedMetrics {
106111 if ! strings .Contains (resultStr , metric ) {
107112 t .Errorf ("Expected metric %q not found in results" , metric )
0 commit comments