MCPcopy
hub / github.com/segmentio/kafka-go / TestDescribeGroupsPartialMembersCleared

Function TestDescribeGroupsPartialMembersCleared

describegroups_test.go:312–372  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

310}
311
312func TestDescribeGroupsPartialMembersCleared(t *testing.T) {
313 mockResp := &describegroups.Response{
314 Groups: []describegroups.ResponseGroup{
315 {
316 ErrorCode: 0,
317 GroupID: "multi-member-group",
318 GroupState: "Stable",
319 ProtocolType: "consumer",
320 Members: []describegroups.ResponseGroupMember{
321 {
322 MemberID: "member-1", // valid
323 ClientID: "client-1",
324 ClientHost: "/127.0.0.1",
325 MemberMetadata: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
326 MemberAssignment: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
327 },
328 {
329 MemberID: "member-2", // invalid
330 ClientID: "client-2",
331 ClientHost: "/127.0.0.1",
332 MemberMetadata: []byte{0x00},
333 MemberAssignment: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
334 },
335 {
336 MemberID: "member-3", // valid, but never processed
337 ClientID: "client-3",
338 ClientHost: "/127.0.0.1",
339 MemberMetadata: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
340 MemberAssignment: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
341 },
342 },
343 },
344 },
345 }
346
347 client := &Client{
348 Transport: &mockRoundTripper{response: mockResp},
349 }
350
351 ctx := context.Background()
352 resp, err := client.DescribeGroups(ctx, &DescribeGroupsRequest{
353 Addr: TCP("localhost:9092"),
354 GroupIDs: []string{"multi-member-group"},
355 })
356
357 if err != nil {
358 t.Fatalf("Unexpected error from DescribeGroups: %v", err)
359 }
360
361 if len(resp.Groups) != 1 {
362 t.Fatalf("Expected 1 group, got %d", len(resp.Groups))
363 }
364
365 group := resp.Groups[0]
366 if group.Error == nil {
367 t.Fatal("Expected group to have an error, got nil")
368 }
369 if len(group.Members) != 0 {

Callers

nothing calls this directly

Calls 2

DescribeGroupsMethod · 0.95
TCPFunction · 0.85

Tested by

no test coverage detected