github.com/argoproj/argo-cd/v3@v3.2.1/server/project/util_test.go (about) 1 package project 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestUnique(t *testing.T) { 11 tests := []struct { 12 name string 13 slice []string 14 want []string 15 }{ 16 { 17 name: "Empty", 18 slice: []string{}, 19 want: []string{}, 20 }, 21 { 22 name: "SingleValue", 23 slice: []string{"foo"}, 24 want: []string{"foo"}, 25 }, 26 { 27 name: "SingleValue2", 28 slice: []string{"foo", "foo"}, 29 want: []string{}, 30 }, 31 { 32 name: "TwoValue", 33 slice: []string{"foo", "bar"}, 34 want: []string{"foo", "bar"}, 35 }, 36 { 37 name: "TwoValues2", 38 slice: []string{"foo", "bar", "foo", "bar"}, 39 want: []string{}, 40 }, 41 } 42 for _, tt := range tests { 43 t.Run(tt.name, func(t *testing.T) { 44 got := unique(tt.slice) 45 assert.Truef(t, reflect.DeepEqual(got, tt.want), "unique() = %v, want %v", got, tt.want) 46 }) 47 } 48 }