Skip to content

test(tui): fix data race on mock UpdateSettings calls - #1844

Merged
wizzomafizzo merged 1 commit into
mainfrom
fix/tui-mock-calls-race
Nov 19, 2026
Merged

wizzomafizzo merged 1 commit into
mainfrom
fix/tui-mock-calls-race

Conversation

@wizzomafizzo

@wizzomafizzo wizzomafizzo commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Several TUI backup and online tests read testify's mockSvc.Calls without its lock while the tview app goroutine was recording new UpdateSettings calls. On Windows and macOS the race detector caught this in TestBuildBackupSettingsMenu_AutoBackupDisabledOnManual_Integration, and every later test in pkg/ui/tui was marked failed.

MockSettingsService now records UpdateSettings params under a mutex and exposes a copy through UpdateSettingsParams(). The three places that read Calls directly now use that method.

Closes #1843

Summary by CodeRabbit

  • Tests
    • Updated settings-related test checks to more consistently verify recorded settings changes.

Tests polled testify's Mock.Calls from another goroutine while the tview
app goroutine recorded new calls, tripping the race detector on Windows
and macOS and failing every remaining test in pkg/ui/tui.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The TUI settings mock now records UpdateSettings parameters behind a mutex and returns a shallow copy. Online and settings tests use this accessor instead of extracting parameters from mock call records.

Changes: TUI Settings Test Updates

Layer / File(s) Summary
Record and inspect settings updates
pkg/ui/tui/mock_api_client_test.go, pkg/ui/tui/online_test.go, pkg/ui/tui/settings_test.go
The mock records update parameters under a mutex and returns a shallow copy. The online and settings tests use the accessor to inspect recorded parameters.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: Minimal · up to 149e8

This change only fixes a data race in TUI test mocks. It does not alter production behavior, and no merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #1843 asks that CI pass on main. It lists failed Windows and macOS CI jobs and a Lint failure, but names no failing test or lint rule. The PR fixes the test-side data race: MockSettingsService.U… Provide the lint failure output from CI run 44534855420 (or the failing lint rule and file). Confirm whether the lint failure is caused by files in this PR or by existing code. If the lint failure has a cause outside this PR, confirm that t…
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the test(tui) scope and the data race fix on mock UpdateSettings calls. The change adds a mutex-protected recording of UpdateSettings parameters, exposes them through UpdateSettingsPar…
Out of Scope Changes check Passed All changes are in pkg/ui/tui test code. The mock adds a mutex-guarded params slice and an accessor. Two test files switch from reading mock Calls to the accessor. The changes support the single state…
Full details: Title check

Explanation

The title names the test(tui) scope and the data race fix on mock UpdateSettings calls. The change adds a mutex-protected recording of UpdateSettings parameters, exposes them through UpdateSettingsParams(), and switches three tests to that accessor, so the title matches the main change. It is specific and concise, and it fits the PR objective of synchronizing mock access in TUI tests.

Full details: Out of Scope Changes check

Explanation

All changes are in pkg/ui/tui test code. The mock adds a mutex-guarded params slice and an accessor. Two test files switch from reading mock Calls to the accessor. The changes support the single stated objective of removing the unsynchronized Calls reads that cause the data race. No production code, unrelated test, or unrelated feature change appears in the reviewed summary.

Full details: Linked Issues check

Explanation

Issue #1843 asks that CI pass on main. It lists failed Windows and macOS CI jobs and a Lint failure, but names no failing test or lint rule. The PR fixes the test-side data race: MockSettingsService.UpdateSettings now appends params under syncutil.Mutex, and UpdateSettingsParams() returns a copy (pkg/ui/tui/mock_api_client_test.go, verified at head). The three direct reads of mockSvc.Calls in online_test.go and settings_test.go now call that accessor. This addresses the race that the PR reports in TestBuildBackupSettingsMenu_AutoBackupDisabledOnManual_Integration. The PR does not address the lint failure, and the CI run logs are not available, so the lint cause is unknown. Compliance with the lint part of #1843 cannot be established.

Resolution

Provide the lint failure output from CI run 44534855420 (or the failing lint rule and file). Confirm whether the lint failure is caused by files in this PR or by existing code. If the lint failure has a cause outside this PR, confirm that the PR's test fix makes the test jobs pass. Then reassess #1843.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 060efb4a-09a3-4da4-bbea-750135f468dc
Commits

Reviewing files that changed from the base of the PR and between b06050b and 149e89a.

Files selected for processing: 3

  • pkg/ui/tui/mock_api_client_test.go
  • pkg/ui/tui/online_test.go
  • pkg/ui/tui/settings_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@wizzomafizzo
wizzomafizzo merged commit fb72d4f into main Nov 19, 2026
18 checks passed
@wizzomafizzo
wizzomafizzo deleted the fix/tui-mock-calls-race branch November 19, 2026 21:43
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI is failing on main

1 participant