Skip to content

Commit 09aaeb0

Browse files
cpcloudclaude
andcommitted
chore: fix G118 in chat tests with t.Cleanup instead of nolint
Use t.Cleanup(cancel) so the context is always cancelled at test end, replacing the nolint suppression. The extraction.go case genuinely cannot be restructured (cancel stored in struct, called on close). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c752c06 commit 09aaeb0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

internal/app/chat_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ func TestCancellationDuringSQLGeneration(t *testing.T) {
120120
m := newTestModel(t)
121121
m.openChat()
122122

123-
_, cancel := context.WithCancel(
124-
context.Background(),
125-
) //nolint:gosec // cancel stored in CancelFn, called by ctrl+c
123+
ctx, cancel := context.WithCancel(context.Background())
124+
t.Cleanup(cancel)
125+
_ = ctx // only the cancel func is needed; ctx is cleaned up via t.Cleanup
126126
m.chat.CurrentQuery = testQuestion
127127
m.chat.Streaming = true
128128
m.chat.StreamingSQL = true
@@ -152,9 +152,9 @@ func TestCancellationDuringAnswerStreaming(t *testing.T) {
152152
m := newTestModel(t)
153153
m.openChat()
154154

155-
_, cancel := context.WithCancel(
156-
context.Background(),
157-
) //nolint:gosec // cancel stored in CancelFn, called by ctrl+c
155+
ctx, cancel := context.WithCancel(context.Background())
156+
t.Cleanup(cancel)
157+
_ = ctx
158158
m.chat.CurrentQuery = testQuestion
159159
m.chat.Streaming = true
160160
m.chat.StreamingSQL = false // stage 2

0 commit comments

Comments
 (0)