Skip to content

Commit 52d6869

Browse files
committed
test(kubernetes): remove unneeded CacheInvalidate() method (mutex lock)
1 parent 329698f commit 52d6869

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/mcp/pods_top_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
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 {

0 commit comments

Comments
 (0)