forked from kai-ten/go-csf-schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
group_test.go
56 lines (47 loc) · 1.07 KB
/
group_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package gcs
import (
"testing"
)
func TestValidNewGroup(t *testing.T) {
group := &Group{
AccountType: "test_type",
Description: "test desc",
Name: "test_name",
Privileges: []string{"test privs"},
UniqueID: "123",
}
group, err := ValidateGroup(group)
if err != nil {
t.Fatalf("Unable to create and validate Group: %v", err)
}
t.Logf("Name = %v", group.Name)
}
func TestErrorInvalidNewGroup(t *testing.T) {
group := &Group{
AccountType: "test_type",
Description: "test desc",
Name: "",
Privileges: []string{"test privs"},
UniqueID: "123",
}
_, err := ValidateGroup(group)
if err == nil {
t.Fatalf("Validator should have flagged this as an error: %v", err)
}
}
func BenchmarkGroupValidation(b *testing.B) {
b.ReportAllocs()
group := &Group{
AccountType: "test_type",
Description: "test desc",
Name: "test_name",
Privileges: []string{"test privs"},
UniqueID: "123",
}
for n := 0; n < b.N; n++ {
_, err := ValidateGroup(group)
if err != nil {
b.Fatalf("Group object is invalid: %v", err)
}
}
}