Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions Morpheus.Tests/YoutubeFeedServiceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Morpheus.Services;

namespace Morpheus.Tests;

public class YoutubeFeedServiceTests
{
[Fact]
public async Task FetchFeedAsync_WhenCallerCancels_PropagatesCancellation()
{
YoutubeFeedService service = new(new LogsService(new LogQueue()));
using CancellationTokenSource cts = new();
cts.Cancel();

await Assert.ThrowsAnyAsync<OperationCanceledException>(() =>
service.FetchFeedAsync("channel-id", cts.Token));
}
}
4 changes: 4 additions & 0 deletions Services/YoutubeFeedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public record VideoEntry(string VideoId, string Title, string Link, DateTime Pub

return (channelTitle, entries);
}
catch (OperationCanceledException) when (ct.IsCancellationRequested)
{
throw;
}
catch (Exception ex)
{
logsService.Log($"Failed to fetch YouTube feed for {channelId}: {ex.Message}", LogSeverity.Warning);
Expand Down