@@ -66,15 +66,16 @@ func createTestToolWithExistingProperties(name string) api.ServerTool {
6666
6767func TestWithClusterParameter (t * testing.T ) {
6868 tests := []struct {
69- name string
70- defaultCluster string
71- clusters []string
72- skipToolNames []string
73- toolName string
74- toolFactory func (string ) api.ServerTool
75- expectCluster bool
76- expectEnum bool
77- enumCount int
69+ name string
70+ defaultCluster string
71+ targetParameterName string
72+ clusters []string
73+ skipToolNames []string
74+ toolName string
75+ toolFactory func (string ) api.ServerTool
76+ expectCluster bool
77+ expectEnum bool
78+ enumCount int
7879 }{
7980 {
8081 name : "adds cluster parameter when multiple clusters provided" ,
@@ -146,7 +147,10 @@ func TestWithClusterParameter(t *testing.T) {
146147
147148 for _ , tt := range tests {
148149 t .Run (tt .name , func (t * testing.T ) {
149- mutator := WithClusterParameter (tt .defaultCluster , tt .clusters , tt .skipToolNames )
150+ if tt .targetParameterName == "" {
151+ tt .targetParameterName = "cluster"
152+ }
153+ mutator := WithTargetParameter (tt .defaultCluster , tt .targetParameterName , tt .clusters , tt .skipToolNames )
150154 tool := tt .toolFactory (tt .toolName )
151155 originalTool := tool // Keep reference to check if tool was unchanged
152156
@@ -192,41 +196,47 @@ func TestCreateClusterProperty(t *testing.T) {
192196 tests := []struct {
193197 name string
194198 defaultCluster string
199+ targetName string
195200 clusters []string
196201 expectEnum bool
197202 expectedCount int
198203 }{
199204 {
200205 name : "creates property with enum when clusters <= maxClustersInEnum" ,
201206 defaultCluster : "default" ,
207+ targetName : "cluster" ,
202208 clusters : []string {"cluster1" , "cluster2" , "cluster3" },
203209 expectEnum : true ,
204210 expectedCount : 3 ,
205211 },
206212 {
207213 name : "creates property without enum when clusters > maxClustersInEnum" ,
208214 defaultCluster : "default" ,
209- clusters : make ([]string , maxClustersInEnum + 5 ), // 20 clusters
215+ targetName : "cluster" ,
216+ clusters : make ([]string , maxTargetsInEnum + 5 ), // 20 clusters
210217 expectEnum : false ,
211218 expectedCount : 0 ,
212219 },
213220 {
214221 name : "creates property with exact maxClustersInEnum clusters" ,
215222 defaultCluster : "default" ,
216- clusters : make ([]string , maxClustersInEnum ),
223+ targetName : "cluster" ,
224+ clusters : make ([]string , maxTargetsInEnum ),
217225 expectEnum : true ,
218- expectedCount : maxClustersInEnum ,
226+ expectedCount : maxTargetsInEnum ,
219227 },
220228 {
221229 name : "handles single cluster" ,
222230 defaultCluster : "default" ,
231+ targetName : "cluster" ,
223232 clusters : []string {"single-cluster" },
224233 expectEnum : true ,
225234 expectedCount : 1 ,
226235 },
227236 {
228237 name : "handles empty clusters list" ,
229238 defaultCluster : "default" ,
239+ targetName : "cluster" ,
230240 clusters : []string {},
231241 expectEnum : true ,
232242 expectedCount : 0 ,
@@ -242,7 +252,7 @@ func TestCreateClusterProperty(t *testing.T) {
242252 }
243253 }
244254
245- property := createClusterProperty (tt .defaultCluster , tt .clusters )
255+ property := createTargetProperty (tt .defaultCluster , tt . targetName , tt .clusters )
246256
247257 assert .Equal (t , "string" , property .Type )
248258 assert .Contains (t , property .Description , tt .defaultCluster )
@@ -279,6 +289,6 @@ func TestToolMutatorType(t *testing.T) {
279289
280290func TestMaxClustersInEnumConstant (t * testing.T ) {
281291 t .Run ("maxClustersInEnum has expected value" , func (t * testing.T ) {
282- assert .Equal (t , 15 , maxClustersInEnum , "maxClustersInEnum should be 15" )
292+ assert .Equal (t , 15 , maxTargetsInEnum , "maxClustersInEnum should be 15" )
283293 })
284294}
0 commit comments