@@ -13,6 +13,7 @@ func TestCleanToolsets(t *testing.T) {
1313 input []string
1414 dynamicToolsets bool
1515 expected []string
16+ expectedInvalid []string
1617 }{
1718 {
1819 name : "empty slice" ,
@@ -211,16 +212,41 @@ func TestCleanToolsets(t *testing.T) {
211212 dynamicToolsets : false ,
212213 expected : []string {"all" },
213214 },
215+ // Invalid toolset test cases
216+ {
217+ name : "mix of valid and invalid toolsets" ,
218+ input : []string {"actions" , "invalid_toolset" , "gists" , "typo_repo" },
219+ dynamicToolsets : false ,
220+ expected : []string {"actions" , "gists" },
221+ expectedInvalid : []string {"invalid_toolset" , "typo_repo" },
222+ },
223+ {
224+ name : "invalid with whitespace" ,
225+ input : []string {" invalid_tool " , " actions " , " typo_gist " },
226+ dynamicToolsets : false ,
227+ expected : []string {"actions" },
228+ expectedInvalid : []string {"invalid_tool" , "typo_gist" },
229+ },
230+ {
231+ name : "empty string in toolsets" ,
232+ input : []string {"" , "actions" , " " , "gists" },
233+ dynamicToolsets : false ,
234+ expected : []string {"actions" , "gists" },
235+ expectedInvalid : []string {},
236+ },
214237 }
215238
216239 for _ , tt := range tests {
217240 t .Run (tt .name , func (t * testing.T ) {
218- result := cleanToolsets (tt .input , tt .dynamicToolsets )
241+ result , invalid := cleanToolsets (tt .input , tt .dynamicToolsets )
219242
220- // Check that the result has the correct length
221243 require .Len (t , result , len (tt .expected ), "result length should match expected length" )
222244
223- // Create a map for easier comparison since order might vary
245+ if tt .expectedInvalid == nil {
246+ tt .expectedInvalid = []string {}
247+ }
248+ require .Len (t , invalid , len (tt .expectedInvalid ), "invalid length should match expected invalid length" )
249+
224250 resultMap := make (map [string ]bool )
225251 for _ , toolset := range result {
226252 resultMap [toolset ] = true
@@ -231,13 +257,21 @@ func TestCleanToolsets(t *testing.T) {
231257 expectedMap [toolset ] = true
232258 }
233259
234- // Check that both maps contain the same toolsets
260+ invalidMap := make (map [string ]bool )
261+ for _ , toolset := range invalid {
262+ invalidMap [toolset ] = true
263+ }
264+
265+ expectedInvalidMap := make (map [string ]bool )
266+ for _ , toolset := range tt .expectedInvalid {
267+ expectedInvalidMap [toolset ] = true
268+ }
269+
235270 assert .Equal (t , expectedMap , resultMap , "result should contain all expected toolsets without duplicates" )
271+ assert .Equal (t , expectedInvalidMap , invalidMap , "invalid should contain all expected invalid toolsets" )
236272
237- // Verify no duplicates in result
238273 assert .Len (t , resultMap , len (result ), "result should not contain duplicates" )
239274
240- // Verify "default" is not in the result
241275 assert .False (t , resultMap ["default" ], "result should not contain 'default'" )
242276 })
243277 }
0 commit comments