Skip to content

Commit 63a61a8

Browse files
committed
Address feedback
1 parent a56ff59 commit 63a61a8

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

kafka/adminapi_test.go

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,11 +1424,13 @@ func TestAdminClientLogWithoutChannel(t *testing.T) {
14241424
t.Fatalf("Expected admin.Logs() to return a channel, got nil")
14251425
}
14261426

1427-
expectedLogs := map[struct {
1427+
// Define expected logs to validate
1428+
expectedLogs := []struct {
14281429
tag string
14291430
message string
1430-
}]bool{
1431-
{"INIT", "librdkafka"}: false,
1431+
found bool
1432+
}{
1433+
{"INIT", "librdkafka", false},
14321434
}
14331435

14341436
go func() {
@@ -1441,15 +1443,11 @@ func TestAdminClientLogWithoutChannel(t *testing.T) {
14411443

14421444
t.Log(log.String())
14431445

1444-
for expectedLog, found := range expectedLogs {
1445-
if found {
1446-
continue
1447-
}
1448-
if log.Tag != expectedLog.tag {
1449-
continue
1450-
}
1451-
if strings.Contains(log.Message, expectedLog.message) {
1452-
expectedLogs[expectedLog] = true
1446+
// Check each expected log
1447+
for i := range expectedLogs {
1448+
if !expectedLogs[i].found && log.Tag == expectedLogs[i].tag &&
1449+
strings.Contains(log.Message, expectedLogs[i].message) {
1450+
expectedLogs[i].found = true
14531451
}
14541452
}
14551453
}
@@ -1458,13 +1456,11 @@ func TestAdminClientLogWithoutChannel(t *testing.T) {
14581456

14591457
<-time.After(time.Second * 5)
14601458

1461-
for expectedLog, found := range expectedLogs {
1462-
if !found {
1463-
t.Errorf(
1464-
"Expected to find log with tag `%s' and message containing `%s',"+
1465-
" but didn't find any.",
1466-
expectedLog.tag,
1467-
expectedLog.message)
1459+
// Validate all expected logs were found
1460+
for _, expected := range expectedLogs {
1461+
if !expected.found {
1462+
t.Errorf("Expected to find log with tag `%s' and message containing `%s', but didn't find any.",
1463+
expected.tag, expected.message)
14681464
}
14691465
}
14701466
}

0 commit comments

Comments
 (0)