File tree Expand file tree Collapse file tree
src/CodexCliPlus.Infrastructure/Backend
tests/CodexCliPlus.Tests/Backend Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,6 +118,8 @@ private async Task<bool> IsExecutableVersionCurrentAsync(
118118 CancellationToken cancellationToken
119119 )
120120 {
121+ cancellationToken . ThrowIfCancellationRequested ( ) ;
122+
121123 if ( TryReadCachedExecutableVersion ( executablePath , out var cachedVersion ) )
122124 {
123125 return IsExpectedBackendVersion ( cachedVersion ) ;
Original file line number Diff line number Diff line change @@ -173,6 +173,32 @@ public async Task IsExecutableVersionCurrentAsyncPropagatesCallerCancellation()
173173 Assert . IsAssignableFrom < OperationCanceledException > ( exception ) ;
174174 }
175175
176+ [ Fact ]
177+ public async Task IsExecutableVersionCurrentAsyncPropagatesCallerCancellationBeforeCacheHit ( )
178+ {
179+ var pathService = new TestPathService ( _rootDirectory ) ;
180+ await pathService . EnsureCreatedAsync ( ) ;
181+ var executablePath = Path . Combine (
182+ pathService . Directories . BackendDirectory ,
183+ BackendExecutableNames . ManagedExecutableFileName
184+ ) ;
185+ await File . WriteAllTextAsync ( executablePath , "managed executable placeholder" ) ;
186+ var service = new BackendAssetService (
187+ new HttpClient ( ) ,
188+ pathService ,
189+ new NullAppLogger ( _rootDirectory )
190+ ) ;
191+ await InvokeWriteVersionCacheAsync ( service , executablePath , BackendReleaseMetadata . Version ) ;
192+ using var cancellation = new CancellationTokenSource ( ) ;
193+ cancellation . Cancel ( ) ;
194+
195+ var exception = await Record . ExceptionAsync ( ( ) =>
196+ InvokeIsExecutableVersionCurrentAsync ( service , executablePath , cancellation . Token )
197+ ) ;
198+
199+ Assert . IsAssignableFrom < OperationCanceledException > ( exception ) ;
200+ }
201+
176202 public void Dispose ( )
177203 {
178204 if ( Directory . Exists ( _rootDirectory ) )
You can’t perform that action at this time.
0 commit comments