-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
acl_types_test.go
73 lines (68 loc) · 1.77 KB
/
acl_types_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package sarama
import (
"testing"
)
func TestAclOperationTextMarshal(t *testing.T) {
for i := AclOperationUnknown; i <= AclOperationIdempotentWrite; i++ {
text, err := i.MarshalText()
if err != nil {
t.Errorf("couldn't marshal %d to text: %s", i, err)
}
var got AclOperation
err = got.UnmarshalText(text)
if err != nil {
t.Errorf("couldn't unmarshal %s to acl operation: %s", text, err)
}
if got != i {
t.Errorf("got %d, want %d", got, i)
}
}
}
func TestAclPermissionTypeTextMarshal(t *testing.T) {
for i := AclPermissionUnknown; i <= AclPermissionAllow; i++ {
text, err := i.MarshalText()
if err != nil {
t.Errorf("couldn't marshal %d to text: %s", i, err)
}
var got AclPermissionType
err = got.UnmarshalText(text)
if err != nil {
t.Errorf("couldn't unmarshal %s to acl permission: %s", text, err)
}
if got != i {
t.Errorf("got %d, want %d", got, i)
}
}
}
func TestAclResourceTypeTextMarshal(t *testing.T) {
for i := AclResourceUnknown; i <= AclResourceTransactionalID; i++ {
text, err := i.MarshalText()
if err != nil {
t.Errorf("couldn't marshal %d to text: %s", i, err)
}
var got AclResourceType
err = got.UnmarshalText(text)
if err != nil {
t.Errorf("couldn't unmarshal %s to acl resource: %s", text, err)
}
if got != i {
t.Errorf("got %d, want %d", got, i)
}
}
}
func TestAclResourcePatternTypeTextMarshal(t *testing.T) {
for i := AclPatternUnknown; i <= AclPatternPrefixed; i++ {
text, err := i.MarshalText()
if err != nil {
t.Errorf("couldn't marshal %d to text: %s", i, err)
}
var got AclResourcePatternType
err = got.UnmarshalText(text)
if err != nil {
t.Errorf("couldn't unmarshal %s to acl resource pattern: %s", text, err)
}
if got != i {
t.Errorf("got %d, want %d", got, i)
}
}
}