-
Notifications
You must be signed in to change notification settings - Fork 6
/
kubernetes-rbac-synchroniser_test.go
42 lines (38 loc) · 1.35 KB
/
kubernetes-rbac-synchroniser_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"testing"
"google.golang.org/api/admin/directory/v1"
)
func TestUniq(t *testing.T) {
uniqUserList1 := uniq(getFakeMembers())
list1Length := len(uniqUserList1)
if list1Length != 1 {
t.Errorf("Uniq was incorrect, got: %d, want: %d.", list1Length, 1)
}
var uniqUserList2 []*admin.Member
var member1 = new(admin.Member)
member1.Email = "[email protected]"
var member2 = new(admin.Member)
member2.Email = "[email protected]"
var member3 = new(admin.Member)
member3.Email = "[email protected]"
uniqUserList2 = append(uniqUserList2, member1)
uniqUserList2 = append(uniqUserList2, member2)
uniqUserList2 = append(uniqUserList2, member1)
uniqUserList2 = append(uniqUserList2, member3)
uniqUserList2 = append(uniqUserList2, member2)
uniqUserList2 = uniq(uniqUserList2)
list2Length := len(uniqUserList2)
if list2Length != 3 {
t.Errorf("Uniq was incorrect, got: %d, want: %d.", list2Length, 3)
}
if uniqUserList2[0].Email != member1.Email {
t.Errorf("Uniq sort was incorrect, got: %q, want: %q.", uniqUserList2[0].Email, member1.Email)
}
if uniqUserList2[1].Email != member2.Email {
t.Errorf("Uniq sort was incorrect, got: %q, want: %q.", uniqUserList2[1].Email, member2.Email)
}
if uniqUserList2[2].Email != member3.Email {
t.Errorf("Uniq sort was incorrect, got: %q, want: %q.", uniqUserList2[2].Email, member3.Email)
}
}