Skip to content

Commit 306533d

Browse files
wesmclaude
andcommitted
Use pre-cancelled context in matching-token test
Prevents hanging on browser auth if regression makes the token non-reusable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fe560dd commit 306533d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/msgvault/cmd/addaccount_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,19 @@ func TestAddAccount_ExplicitDefaultAcceptsMatchingToken(t *testing.T) {
392392
testCmd.Flags().BoolVar(&forceReauth, "force", false, "")
393393
testCmd.Flags().StringVar(&accountDisplayName, "display-name", "", "")
394394

395+
// Pre-cancel so if regression causes auth attempt, it fails fast
396+
// instead of opening a browser.
397+
ctx, cancel := context.WithCancel(context.Background())
398+
cancel()
399+
395400
root := newTestRootCmd()
396401
root.AddCommand(testCmd)
397402
root.SetArgs([]string{
398403
"add-account", "user@example.com", "--oauth-app", "",
399404
})
400405

401-
// Should succeed: token's client_id matches default secrets
402-
err := root.Execute()
406+
// Should succeed: token's client_id matches, no auth needed
407+
err := root.ExecuteContext(ctx)
403408
if err != nil {
404409
t.Fatalf("unexpected error: %v", err)
405410
}

0 commit comments

Comments
 (0)