@@ -270,36 +270,33 @@ func TestSaramaClient_CreatePartitionsFailure(t *testing.T) {
270270 assert .Error (t , err )
271271 admin .AssertExpectations (t )
272272}
273-
274- type mockGroupDescription interface {
275- GetMemberAssignment () (* sarama.ConsumerGroupMemberAssignment , error )
276- }
277-
278- type mockMemberAssignment struct {}
279-
280- func (m * mockMemberAssignment ) GetMemberAssignment () (* sarama.ConsumerGroupMemberAssignment , error ) {
281- return & sarama.ConsumerGroupMemberAssignment {
282- Version : 1 ,
283- Topics : map [string ][]int32 {"t1" : {0 , 1 , 2 }},
284- UserData : []byte ("ss" ),
285- }, nil
286- }
287-
288- type mockGroupDescriptionStruct struct {
289- GroupId string
290- Members map [string ]mockMemberAssignment
291- }
292-
293273func TestSaramaClient_GetConsumerGroupsForTopic (t * testing.T ) {
294274 admin := & MockClusterAdmin {}
295275 client := SaramaClient {admin : admin }
296276
297- admin .On ("DescribeConsumerGroups" , []string {"c1" }).Return ([]* mockGroupDescriptionStruct {{
298- GroupId : "c1" ,
299- Members : map [string ]mockMemberAssignment {"k1" : {}},
300- }}, nil )
277+ groupDesciption := []* sarama.GroupDescription {{
278+ GroupId : "test-group-id" ,
279+ Members : map [string ]* sarama.GroupMemberDescription {
280+ "instance-id-0" : {
281+ ClientId : "instance-id-0" ,
282+ MemberAssignment : []byte {0x04 , 0x05 , 0x06 },
283+ },
284+
285+ "instance-id-1" : {
286+ ClientId : "instance-id-1" ,
287+ MemberAssignment : []byte {0x04 , 0x05 , 0x06 },
288+ },
289+
290+ "instance-id-2" : {
291+ ClientId : "instance-id-2" ,
292+ MemberAssignment : []byte {0x04 , 0x05 , 0x06 },
293+ },
294+ },
295+ }}
296+
297+ admin .On ("DescribeConsumerGroups" , []string {"test-group-id" }).Return (groupDesciption , nil )
301298
302- consumerGroupChannel , err := client .GetConsumerGroupsForTopic ([]string {"c1 " }, "t1 " )
299+ consumerGroupChannel , err := client .GetConsumerGroupsForTopic ([]string {"test-group-id " }, "test-topic " )
303300
304301 require .NoError (t , err )
305302 assert .Equal (t , 1 , len (consumerGroupChannel ))
0 commit comments