File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 44 "github.com/mark3labs/mcp-go/mcp"
55 "net/http"
66 "regexp"
7+ "sync"
78 "testing"
89)
910
@@ -13,8 +14,11 @@ func TestPodsTop(t *testing.T) {
1314 defer mockServer .Close ()
1415 c .withKubeConfig (mockServer .config )
1516 metricsApiAvailable := false
17+ metricsApiMutex := sync.Mutex {}
1618 mockServer .Handle (http .HandlerFunc (func (w http.ResponseWriter , req * http.Request ) {
1719 println ("Request received:" , req .Method , req .URL .Path ) // TODO: REMOVE LINE
20+ metricsApiMutex .Lock ()
21+ defer metricsApiMutex .Unlock ()
1822 w .Header ().Set ("Content-Type" , "application/json" )
1923 // Request Performed by DiscoveryClient to Kube API (Get API Groups legacy -core-)
2024 if req .URL .Path == "/api" {
@@ -85,7 +89,9 @@ func TestPodsTop(t *testing.T) {
8589 }
8690 })
8791 // Enable metrics API addon
92+ metricsApiMutex .Lock ()
8893 metricsApiAvailable = true
94+ metricsApiMutex .Unlock ()
8995 podsTopDefaults , err := c .callTool ("pods_top" , map [string ]interface {}{})
9096 t .Run ("pods_top defaults returns pod metrics from all namespaces" , func (t * testing.T ) {
9197 if err != nil {
You can’t perform that action at this time.
0 commit comments