fix: context leak in TestChatStream_EarlyCancel
Add defer cancel() so the context is always cancelled, even when the loop exits early due to an error before reaching 5 events. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
72c4066210
commit
5bebfce972
1 changed files with 1 additions and 0 deletions
|
|
@ -637,6 +637,7 @@ func TestChatStream_EarlyCancel(t *testing.T) {
|
|||
p := NewProviderWithOptions("key", server.URL, "", Options{Stream: true})
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ch, err := p.ChatStream(ctx, []Message{{Role: "user", Content: "hi"}}, nil, "test", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("ChatStream() error = %v", err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue