(t *testing.T)
| 258 | } |
| 259 | |
| 260 | func TestDescribeGroupsInvalidAssignments(t *testing.T) { |
| 261 | // Test the case where assignments are invalid but metadata is valid |
| 262 | mockResp := &describegroups.Response{ |
| 263 | Groups: []describegroups.ResponseGroup{ |
| 264 | { |
| 265 | ErrorCode: 0, |
| 266 | GroupID: "group-with-bad-assignments", |
| 267 | GroupState: "Stable", |
| 268 | ProtocolType: "consumer", |
| 269 | Members: []describegroups.ResponseGroupMember{ |
| 270 | { |
| 271 | MemberID: "member-1", |
| 272 | ClientID: "client-1", |
| 273 | ClientHost: "/127.0.0.1", |
| 274 | // Valid metadata |
| 275 | MemberMetadata: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
| 276 | // Invalid assignments - truncated |
| 277 | MemberAssignment: []byte{0x00}, |
| 278 | }, |
| 279 | }, |
| 280 | }, |
| 281 | }, |
| 282 | } |
| 283 | |
| 284 | client := &Client{ |
| 285 | Transport: &mockRoundTripper{response: mockResp}, |
| 286 | } |
| 287 | |
| 288 | ctx := context.Background() |
| 289 | resp, err := client.DescribeGroups(ctx, &DescribeGroupsRequest{ |
| 290 | Addr: TCP("localhost:9092"), |
| 291 | GroupIDs: []string{"group-with-bad-assignments"}, |
| 292 | }) |
| 293 | |
| 294 | if err != nil { |
| 295 | t.Fatalf("Unexpected error from DescribeGroups: %v", err) |
| 296 | } |
| 297 | |
| 298 | // Verify we got the group back with an error |
| 299 | if len(resp.Groups) != 1 { |
| 300 | t.Fatalf("Expected 1 group, got %d", len(resp.Groups)) |
| 301 | } |
| 302 | |
| 303 | if resp.Groups[0].Error == nil { |
| 304 | t.Error("Expected group to have an error for invalid assignments, got nil") |
| 305 | } |
| 306 | |
| 307 | if len(resp.Groups[0].Members) != 0 { |
| 308 | t.Errorf("Expected group to have 0 members due to error, got %d", len(resp.Groups[0].Members)) |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | func TestDescribeGroupsPartialMembersCleared(t *testing.T) { |
| 313 | mockResp := &describegroups.Response{ |
nothing calls this directly
no test coverage detected