feat(push): add service-owned firebase channels and delivery
Add push contracts, provider delivery and channel diagnostics. Link email channels to services and document migration and validation. Ref: IT-1074
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
namespace HrynCo.NotificationService.Web.IntegrationTests;
|
||||
|
||||
using HrynCo.NotificationService.DAL.Abstract.Push;
|
||||
using HrynCo.NotificationService.DAL.EF;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
public sealed class PushDeliveryRepositoryTests(TemplateDatabaseFixture fixture) : IClassFixture<TemplateDatabaseFixture>
|
||||
{
|
||||
[Fact]
|
||||
public async Task RedeliveryReplaysOutcomeAndFailedProviderCallCanRetry()
|
||||
{
|
||||
var connection = await fixture.CreateDatabaseAsync();
|
||||
using var provider = new ServiceCollection().AddNotificationDataAccess(connection).BuildServiceProvider();
|
||||
var id = Guid.NewGuid();
|
||||
using (var first = provider.CreateScope())
|
||||
{
|
||||
var repository = first.ServiceProvider.GetRequiredService<IPushDeliveryRepository>();
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() => repository.DeliverOnceAsync(id, "Invemory",
|
||||
_ => throw new InvalidOperationException("transient"), default));
|
||||
}
|
||||
using (var retry = provider.CreateScope())
|
||||
{
|
||||
var repository = retry.ServiceProvider.GetRequiredService<IPushDeliveryRepository>();
|
||||
var result = await repository.DeliverOnceAsync(id, "Invemory",
|
||||
_ => Task.FromResult(new PushDeliveryOutcome("unregistered", true)), default);
|
||||
Assert.True(result.InvalidRegistration);
|
||||
}
|
||||
using var redelivery = provider.CreateScope();
|
||||
var saved = await redelivery.ServiceProvider.GetRequiredService<IPushDeliveryRepository>()
|
||||
.DeliverOnceAsync(id, "Invemory", _ => throw new Exception("must not send twice"), default);
|
||||
Assert.Equal("unregistered", saved.Error);
|
||||
Assert.True(saved.InvalidRegistration);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user