Skip to content

Commit 8e269d4

Browse files
committed
add tests for trimming and deduplication
1 parent bf9d382 commit 8e269d4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

pkg/inventory/registry_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,36 @@ func TestUnrecognizedTools(t *testing.T) {
315315
withTools: []string{},
316316
expectedUnrecognized: nil,
317317
},
318+
{
319+
name: "whitespace trimmed from valid tool",
320+
withTools: []string{" tool1 ", " tool2 "},
321+
expectedUnrecognized: nil,
322+
},
323+
{
324+
name: "whitespace trimmed from invalid tool",
325+
withTools: []string{" invalid_tool "},
326+
expectedUnrecognized: []string{"invalid_tool"},
327+
},
328+
{
329+
name: "duplicate tools deduplicated",
330+
withTools: []string{"tool1", "tool1"},
331+
expectedUnrecognized: nil,
332+
},
333+
{
334+
name: "duplicate invalid tools deduplicated",
335+
withTools: []string{"blabla", "blabla"},
336+
expectedUnrecognized: []string{"blabla"},
337+
},
338+
{
339+
name: "mixed whitespace and duplicates",
340+
withTools: []string{" tool1 ", "tool1", " tool1 "},
341+
expectedUnrecognized: nil,
342+
},
343+
{
344+
name: "empty strings ignored",
345+
withTools: []string{"", "tool1", " ", ""},
346+
expectedUnrecognized: nil,
347+
},
318348
}
319349

320350
for _, tt := range tests {

0 commit comments

Comments
 (0)