mirror of
https://github.com/VGEAREN/Stockbar.git
synced 2026-10-07 13:28:14 +08:00
PRIOR BEHAVIOR (data-loss bug): AppStateTests.setUp() constructed AppState() directly, which used the real ~/Library/Application Support/Stockbar/ for stocks.json. Each test method that did 'sut.stocks = [s1, s2]' triggered didSet → saveStocks → silently overwrote the user's actual portfolio file with 2 test entries. backupIfNeeded then rolled all 10 backup snapshots forward, eventually erasing every historical copy of real data. This destroyed a user's 29-stock portfolio when xcodebuild test was run during Korean stock feature development (2026-05-14 10:08). FIX: - AppState gains a static appSupportDirOverride: URL? hook - AppStateTests.setUp() creates a unique tmpDir, sets the override, tearDown resets and removes the directory - Verified: after running all 7 AppStateTests, the real stocks.json is byte-identical to before the run. This must land before any further test run touches AppState.