@@ -26,40 +26,87 @@ func TestConfigurationView(t *testing.T) {
2626 })
2727 t .Run ("configuration_view returns current-context" , func (t * testing.T ) {
2828 if decoded .CurrentContext != "fake-context" {
29- t .Fatalf ("fake-context not found: %v" , decoded .CurrentContext )
29+ t .Errorf ("fake-context not found: %v" , decoded .CurrentContext )
3030 }
3131 })
3232 t .Run ("configuration_view returns context info" , func (t * testing.T ) {
3333 if len (decoded .Contexts ) != 1 {
34- t .Fatalf ("invalid context count, expected 1, got %v" , len (decoded .Contexts ))
34+ t .Errorf ("invalid context count, expected 1, got %v" , len (decoded .Contexts ))
3535 }
3636 if decoded .Contexts [0 ].Name != "fake-context" {
37- t .Fatalf ("fake-context not found: %v" , decoded .Contexts )
37+ t .Errorf ("fake-context not found: %v" , decoded .Contexts )
3838 }
3939 if decoded .Contexts [0 ].Context .Cluster != "fake" {
40- t .Fatalf ("fake-cluster not found: %v" , decoded .Contexts )
40+ t .Errorf ("fake-cluster not found: %v" , decoded .Contexts )
4141 }
4242 if decoded .Contexts [0 ].Context .AuthInfo != "fake" {
43- t .Fatalf ("fake-auth not found: %v" , decoded .Contexts )
43+ t .Errorf ("fake-auth not found: %v" , decoded .Contexts )
4444 }
4545 })
4646 t .Run ("configuration_view returns cluster info" , func (t * testing.T ) {
4747 if len (decoded .Clusters ) != 1 {
48- t .Fatalf ("invalid cluster count, expected 1, got %v" , len (decoded .Clusters ))
48+ t .Errorf ("invalid cluster count, expected 1, got %v" , len (decoded .Clusters ))
4949 }
5050 if decoded .Clusters [0 ].Name != "fake" {
51- t .Fatalf ("fake-cluster not found: %v" , decoded .Clusters )
51+ t .Errorf ("fake-cluster not found: %v" , decoded .Clusters )
5252 }
5353 if decoded .Clusters [0 ].Cluster .Server != "https://example.com" {
54- t .Fatalf ("fake-server not found: %v" , decoded .Clusters )
54+ t .Errorf ("fake-server not found: %v" , decoded .Clusters )
5555 }
5656 })
5757 t .Run ("configuration_view returns auth info" , func (t * testing.T ) {
5858 if len (decoded .AuthInfos ) != 1 {
59- t .Fatalf ("invalid auth info count, expected 1, got %v" , len (decoded .AuthInfos ))
59+ t .Errorf ("invalid auth info count, expected 1, got %v" , len (decoded .AuthInfos ))
6060 }
6161 if decoded .AuthInfos [0 ].Name != "fake" {
62- t .Fatalf ("fake-auth not found: %v" , decoded .AuthInfos )
62+ t .Errorf ("fake-auth not found: %v" , decoded .AuthInfos )
63+ }
64+ })
65+ toolResult , err = c .callTool ("configuration_view" , map [string ]interface {}{
66+ "minified" : false ,
67+ })
68+ t .Run ("configuration_view with minified=false returns configuration" , func (t * testing.T ) {
69+ if err != nil {
70+ t .Fatalf ("call tool failed %v" , err )
71+ }
72+ })
73+ err = yaml .Unmarshal ([]byte (toolResult .Content [0 ].(mcp.TextContent ).Text ), & decoded )
74+ t .Run ("configuration_view with minified=false has yaml content" , func (t * testing.T ) {
75+ if err != nil {
76+ t .Fatalf ("invalid tool result content %v" , err )
77+ }
78+ })
79+ t .Run ("configuration_view with minified=false returns additional context info" , func (t * testing.T ) {
80+ if len (decoded .Contexts ) != 2 {
81+ t .Errorf ("invalid context count, expected2, got %v" , len (decoded .Contexts ))
82+ }
83+ if decoded .Contexts [0 ].Name != "additional-context" {
84+ t .Errorf ("additional-context not found: %v" , decoded .Contexts )
85+ }
86+ if decoded .Contexts [0 ].Context .Cluster != "additional-cluster" {
87+ t .Errorf ("additional-cluster not found: %v" , decoded .Contexts )
88+ }
89+ if decoded .Contexts [0 ].Context .AuthInfo != "additional-auth" {
90+ t .Errorf ("additional-auth not found: %v" , decoded .Contexts )
91+ }
92+ if decoded .Contexts [1 ].Name != "fake-context" {
93+ t .Errorf ("fake-context not found: %v" , decoded .Contexts )
94+ }
95+ })
96+ t .Run ("configuration_view with minified=false returns cluster info" , func (t * testing.T ) {
97+ if len (decoded .Clusters ) != 2 {
98+ t .Errorf ("invalid cluster count, expected 2, got %v" , len (decoded .Clusters ))
99+ }
100+ if decoded .Clusters [0 ].Name != "additional-cluster" {
101+ t .Errorf ("additional-cluster not found: %v" , decoded .Clusters )
102+ }
103+ })
104+ t .Run ("configuration_view with minified=false returns auth info" , func (t * testing.T ) {
105+ if len (decoded .AuthInfos ) != 2 {
106+ t .Errorf ("invalid auth info count, expected 2, got %v" , len (decoded .AuthInfos ))
107+ }
108+ if decoded .AuthInfos [0 ].Name != "additional-auth" {
109+ t .Errorf ("additional-auth not found: %v" , decoded .AuthInfos )
63110 }
64111 })
65112 })
0 commit comments