Skip to content

Commit af056ae

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

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,6 +14,7 @@ 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
1820
w.Header().Set("Content-Type", "application/json")
@@ -72,7 +74,9 @@ func TestPodsTop(t *testing.T) {
7274
`}`))
7375
}
7476
}))
77+
metricsApiMutex.Lock()
7578
podsTopMetricsApiUnavailable, err := c.callTool("pods_top", map[string]interface{}{})
79+
metricsApiMutex.Unlock()
7680
t.Run("pods_top with metrics API not available", func(t *testing.T) {
7781
if err != nil {
7882
t.Fatalf("call tool failed %v", err)
@@ -85,8 +89,10 @@ func TestPodsTop(t *testing.T) {
8589
}
8690
})
8791
// Enable metrics API addon
92+
metricsApiMutex.Lock()
8893
metricsApiAvailable = true
8994
podsTopDefaults, err := c.callTool("pods_top", map[string]interface{}{})
95+
metricsApiMutex.Unlock()
9096
t.Run("pods_top defaults returns pod metrics from all namespaces", func(t *testing.T) {
9197
if err != nil {
9298
t.Fatalf("call tool failed %v", err)

0 commit comments

Comments
 (0)