Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions tests/Aspire.Cli.Tests/NuGet/NuGetPackagePrefetcherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,25 @@ public async Task PrefetchingCancellationDueToShutdownLogsCleanMessage()

var packagingService = new TestPackagingService
{
GetChannelsAsyncCallback = async _ =>
// Wait on the token the prefetcher passes in, not stoppingCts.Token. BackgroundService links
// its stopping token to stoppingCts during StartAsync, so a registration made here on
// stoppingCts.Token runs before the linked token is cancelled. The OCE could then reach the
// prefetcher's "when (stoppingToken.IsCancellationRequested)" filter before the filter is
// true, logging the non-fatal Debug message instead of the expected cancellation message.
GetChannelsAsyncCallback = async cancellationToken =>
{
templateArrived.SetResult();
await AsyncTestHelpers.WaitForCancellationAsync(stoppingCts.Token);
await AsyncTestHelpers.WaitForCancellationAsync(cancellationToken);
throw new UnreachableException();
}
};

var updateNotifier = new TestCliUpdateNotifier
{
CheckForCliUpdatesAsyncCallback = async (_, _) =>
CheckForCliUpdatesAsyncCallback = async (_, cancellationToken) =>
{
cliArrived.SetResult();
await AsyncTestHelpers.WaitForCancellationAsync(stoppingCts.Token);
await AsyncTestHelpers.WaitForCancellationAsync(cancellationToken);
}
};

Expand Down
Loading