From 1bd0b32976d3ccc24893d85a80bd68d8ad3de338 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Tue, 26 Aug 2025 15:38:05 +0200 Subject: [PATCH] test: misc fixes and typos (#284) Signed-off-by: Marc Nuri --- pkg/mcp/helm_test.go | 9 +++++---- pkg/mcp/mcp_tools_test.go | 7 ++++--- pkg/mcp/namespaces_test.go | 7 ++++--- pkg/mcp/pods_exec_test.go | 6 +++--- pkg/mcp/pods_test.go | 2 +- pkg/mcp/profiles_test.go | 3 ++- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/pkg/mcp/helm_test.go b/pkg/mcp/helm_test.go index 2195b20..ac83764 100644 --- a/pkg/mcp/helm_test.go +++ b/pkg/mcp/helm_test.go @@ -3,17 +3,18 @@ package mcp import ( "context" "encoding/base64" + "path/filepath" + "runtime" + "strings" + "testing" + "github.com/containers/kubernetes-mcp-server/pkg/config" "github.com/mark3labs/mcp-go/mcp" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "path/filepath" - "runtime" "sigs.k8s.io/yaml" - "strings" - "testing" ) func TestHelmInstall(t *testing.T) { diff --git a/pkg/mcp/mcp_tools_test.go b/pkg/mcp/mcp_tools_test.go index 4d12d30..9ca8cf1 100644 --- a/pkg/mcp/mcp_tools_test.go +++ b/pkg/mcp/mcp_tools_test.go @@ -1,13 +1,14 @@ package mcp import ( - "github.com/mark3labs/mcp-go/client/transport" - "github.com/mark3labs/mcp-go/mcp" - "k8s.io/utils/ptr" "regexp" "strings" "testing" + "github.com/mark3labs/mcp-go/client/transport" + "github.com/mark3labs/mcp-go/mcp" + "k8s.io/utils/ptr" + "github.com/containers/kubernetes-mcp-server/pkg/config" ) diff --git a/pkg/mcp/namespaces_test.go b/pkg/mcp/namespaces_test.go index c3d5a41..fb45568 100644 --- a/pkg/mcp/namespaces_test.go +++ b/pkg/mcp/namespaces_test.go @@ -1,6 +1,10 @@ package mcp import ( + "regexp" + "slices" + "testing" + "github.com/containers/kubernetes-mcp-server/pkg/config" "github.com/containers/kubernetes-mcp-server/pkg/output" "github.com/mark3labs/mcp-go/mcp" @@ -8,10 +12,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" - "regexp" "sigs.k8s.io/yaml" - "slices" - "testing" ) func TestNamespacesList(t *testing.T) { diff --git a/pkg/mcp/pods_exec_test.go b/pkg/mcp/pods_exec_test.go index de5c00b..58c8702 100644 --- a/pkg/mcp/pods_exec_test.go +++ b/pkg/mcp/pods_exec_test.go @@ -58,7 +58,7 @@ func TestPodsExec(t *testing.T) { t.Fatalf("call tool failed %v", err) } if podsExecNilNamespace.IsError { - t.Fatalf("call tool failed") + t.Fatalf("call tool failed: %v", podsExecNilNamespace.Content) } if !strings.Contains(podsExecNilNamespace.Content[0].(mcp.TextContent).Text, "command:ls -l\n") { t.Errorf("unexpected result %v", podsExecNilNamespace.Content[0].(mcp.TextContent).Text) @@ -74,9 +74,9 @@ func TestPodsExec(t *testing.T) { t.Fatalf("call tool failed %v", err) } if podsExecInNamespace.IsError { - t.Fatalf("call tool failed") + t.Fatalf("call tool failed: %v", podsExecInNamespace.Content) } - if !strings.Contains(podsExecNilNamespace.Content[0].(mcp.TextContent).Text, "command:ls -l\n") { + if !strings.Contains(podsExecInNamespace.Content[0].(mcp.TextContent).Text, "command:ls -l\n") { t.Errorf("unexpected result %v", podsExecInNamespace.Content[0].(mcp.TextContent).Text) } }) diff --git a/pkg/mcp/pods_test.go b/pkg/mcp/pods_test.go index de65afa..52a528d 100644 --- a/pkg/mcp/pods_test.go +++ b/pkg/mcp/pods_test.go @@ -94,7 +94,7 @@ func TestPodsListInAllNamespacesUnauthorized(t *testing.T) { return } if toolResult.IsError { - t.Fatalf("call tool failed") + t.Fatalf("call tool failed %v", toolResult.Content) return } }) diff --git a/pkg/mcp/profiles_test.go b/pkg/mcp/profiles_test.go index 4973595..e0bc1b4 100644 --- a/pkg/mcp/profiles_test.go +++ b/pkg/mcp/profiles_test.go @@ -1,10 +1,11 @@ package mcp import ( - "github.com/mark3labs/mcp-go/mcp" "slices" "strings" "testing" + + "github.com/mark3labs/mcp-go/mcp" ) func TestFullProfileTools(t *testing.T) {