test(events): use t.Context() in stream error tests

forbidigo rejects context.Background() in tests; t.Context() is the
intended replacement and carries the test's cancellation.

Signed-off-by: Zhuoming Wang <zhuomingwang0901@outlook.com>
This commit is contained in:
Zhuoming Wang 2026-11-03 21:02:32 +08:00 • committed by Nicolas De loof
parent a74e89a7cc
commit ac8b2cd44e

View file

@ -17,7 +17,6 @@
package inspect
import (
"context"
"errors"
"io"
"testing"
@ -42,7 +41,7 @@ func TestEventsTreatsEOFAsCompletion(t *testing.T) {
})
service := New(&fakeBackend{apiClient: apiClient})
err := service.Events(context.Background(), "project", api.EventsOptions{
err := service.Events(t.Context(), "project", api.EventsOptions{
Consumer: func(api.Event) error { return nil },
})
@ -61,7 +60,7 @@ func TestEventsPropagatesStreamErrors(t *testing.T) {
})
service := New(&fakeBackend{apiClient: apiClient})
err := service.Events(context.Background(), "project", api.EventsOptions{
err := service.Events(t.Context(), "project", api.EventsOptions{
Consumer: func(api.Event) error { return nil },
})