Skip to content

Commit

Permalink
refactor: improve logging clarity and testing robustness across modules
Browse files Browse the repository at this point in the history
- Replace `m.Bytes()` with `m.Payload()` in log statements for better clarity

Signed-off-by: Bo-Yi Wu <[email protected]>
  • Loading branch information
appleboy committed Jan 20, 2025
1 parent 68933cb commit 38cc79e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func TestJobReachTimeout(t *testing.T) {
for {
select {
case <-ctx.Done():
log.Println("get data:", string(m.Bytes()))
log.Println("get data:", string(m.Payload()))
if errors.Is(ctx.Err(), context.Canceled) {
log.Println("queue has been shutdown and cancel the job")
} else if errors.Is(ctx.Err(), context.DeadlineExceeded) {
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestCancelJobAfterShutdown(t *testing.T) {
for {
select {
case <-ctx.Done():
log.Println("get data:", string(m.Bytes()))
log.Println("get data:", string(m.Payload()))
if errors.Is(ctx.Err(), context.Canceled) {
log.Println("queue has been shutdown and cancel the job")
} else if errors.Is(ctx.Err(), context.DeadlineExceeded) {
Expand Down Expand Up @@ -333,15 +333,15 @@ func TestGoroutineLeak(t *testing.T) {
for {
select {
case <-ctx.Done():
log.Println("get data:", string(m.Bytes()))
log.Println("get data:", string(m.Payload()))
if errors.Is(ctx.Err(), context.Canceled) {
log.Println("queue has been shutdown and cancel the job")
} else if errors.Is(ctx.Err(), context.DeadlineExceeded) {
log.Println("job deadline exceeded")
}
return nil
default:
log.Println("get data:", string(m.Bytes()))
log.Println("get data:", string(m.Payload()))
time.Sleep(50 * time.Millisecond)
return nil
}
Expand Down

0 comments on commit 38cc79e

Please sign in to comment.