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