@@ -26,40 +26,87 @@ func TestConfigurationView(t *testing.T) {
26
26
})
27
27
t .Run ("configuration_view returns current-context" , func (t * testing.T ) {
28
28
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 )
30
30
}
31
31
})
32
32
t .Run ("configuration_view returns context info" , func (t * testing.T ) {
33
33
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 ))
35
35
}
36
36
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 )
38
38
}
39
39
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 )
41
41
}
42
42
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 )
44
44
}
45
45
})
46
46
t .Run ("configuration_view returns cluster info" , func (t * testing.T ) {
47
47
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 ))
49
49
}
50
50
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 )
52
52
}
53
53
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 )
55
55
}
56
56
})
57
57
t .Run ("configuration_view returns auth info" , func (t * testing.T ) {
58
58
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 ))
60
60
}
61
61
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 )
63
110
}
64
111
})
65
112
})
0 commit comments