Skip to content

Commit

Permalink
shared/util_test: Add test for helper function RemoveDuplicatesFromSlice
Browse files Browse the repository at this point in the history
Signed-off-by: Din Music <[email protected]>
  • Loading branch information
MusicDin committed Oct 11, 2023
1 parent 133441f commit 09a198e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions shared/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,34 @@ func TestRemoveElementsFromStringSlice(t *testing.T) {
assert.ElementsMatch(t, tt.expectedList, gotList)
}
}

func TestRemoveDuplicatesFromSlice(t *testing.T) {
type test struct {
list []string
expectedlist []string
}

tests := []test{
{
list: []string{},
expectedlist: []string{},
},
{
list: []string{"one"},
expectedlist: []string{"one"},
},
{
list: []string{"one", "one"},
expectedlist: []string{"one"},
},
{
list: []string{"one", "two", "one", "two", "three", "three"},
expectedlist: []string{"one", "two", "three"},
},
}

for _, tt := range tests {
gotList := RemoveDuplicatesFromSlice(tt.list)
assert.ElementsMatch(t, tt.expectedlist, gotList)
}
}

0 comments on commit 09a198e

Please sign in to comment.