argo-cd/server/project/util_test.go
Matthieu MOREL 993d79ca27
chore: use testify instead of testing.Fatal or testing.Error in server (#20755)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-11 20:35:19 -05:00

48 lines
847 B
Go

package project
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestUnique(t *testing.T) {
tests := []struct {
name string
slice []string
want []string
}{
{
name: "Empty",
slice: []string{},
want: []string{},
},
{
name: "SingleValue",
slice: []string{"foo"},
want: []string{"foo"},
},
{
name: "SingleValue2",
slice: []string{"foo", "foo"},
want: []string{},
},
{
name: "TwoValue",
slice: []string{"foo", "bar"},
want: []string{"foo", "bar"},
},
{
name: "TwoValues2",
slice: []string{"foo", "bar", "foo", "bar"},
want: []string{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := unique(tt.slice)
assert.Truef(t, reflect.DeepEqual(got, tt.want), "unique() = %v, want %v", got, tt.want)
})
}
}