-
Notifications
You must be signed in to change notification settings - Fork 18
/
delete_acls_response_test.go
60 lines (49 loc) · 1.56 KB
/
delete_acls_response_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
package healer
import (
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestDeleteAclsResponseEncodeDecode(t *testing.T) {
convey.Convey("Test DeleteAclsResponse Encode and Decode", t, func() {
for _, version := range availableVersions[API_DeleteAcls] {
t.Logf("version: %v", version)
var resourceName = "test-topic"
var principal = "User:test"
var host = "*"
var errorMsg = "mock error"
header := NewResponseHeader(API_DeleteAcls, version)
matchingAcl := DeleteAclsMatchingAcl{
ErrorCode: 0,
ErrorMessage: nil,
ResourceType: 2, // Topic
ResourceName: resourceName,
PatternType: 3, // Match
Principal: principal,
Host: host,
Operation: 2, // Write
PermissionType: 3, // Allow
TaggedFields: mockTaggedFields(header.IsFlexible()),
}
if version == 0 {
matchingAcl.PatternType = 0
}
filterResult := DeleteAclsFilterResult{
ErrorCode: 1,
ErrorMessage: &errorMsg,
MatchingAcls: []DeleteAclsMatchingAcl{matchingAcl},
TaggedFields: mockTaggedFields(header.IsFlexible()),
}
response := &DeleteAclsResponse{
ResponseHeader: header,
ThrottleTimeMs: 100,
FilterResults: []DeleteAclsFilterResult{filterResult, filterResult},
TaggedFields: mockTaggedFields(header.IsFlexible()),
}
response.ResponseHeader.CorrelationID = 100
encoded := response.Encode()
decoded, err := DecodeDeleteAclsResponse(encoded, version)
convey.So(err, convey.ShouldBeNil)
convey.So(decoded, convey.ShouldResemble, response)
}
})
}