Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,51 @@ public async Task ExpireProposalsAsync_ShouldLogArchivedBoardSkipOnlyOnCountTran
entry => entry.Level == LogLevel.Debug && entry.Message.Contains("Still skipping"));
}

[Fact]
public async Task ExpireProposalsAsync_ShouldLogWhenArchivedBoardSkipCountReturnsToZero()
{
var logger = new InMemoryLogger<AutomationProposalService>();
var service = new AutomationProposalService(
_unitOfWorkMock.Object,
_notificationServiceMock.Object,
provenanceRepository: null,
policyEngine: null,
logger: logger);
var expirable = CreatePendingProposal();

_proposalRepoMock
.SetupSequence(r => r.GetExpiredAsync(It.IsAny<CancellationToken>()))
.ReturnsAsync(new ExpiredProposalSweep(
Array.Empty<AutomationProposal>(),
SkippedArchivedBoardCount: 2))
.ReturnsAsync(new ExpiredProposalSweep(
new[] { expirable },
SkippedArchivedBoardCount: 0));

await service.ExpireProposalsAsync();
var result = await service.ExpireProposalsAsync();

result.IsSuccess.Should().BeTrue();
result.Value.Should().Be(1);
expirable.Status.Should().Be(ProposalStatus.Expired);
_unitOfWorkMock.Verify(
u => u.SaveChangesAsync(It.IsAny<CancellationToken>()),
Times.Once());
_notificationServiceMock.Verify(
s => s.PublishAsync(It.IsAny<CreateNotificationRequestDto>(), It.IsAny<CancellationToken>()),
Times.Once());

logger.Entries.Should().ContainSingle(
entry => entry.Level == LogLevel.Information
&& entry.Message.Contains("No stale proposals are being withheld"));
logger.Entries.Should().ContainSingle(
entry => entry.Level == LogLevel.Information
&& entry.Message.Contains("Skipped expiring")
&& entry.Message.Contains("2"));
logger.Entries.Should().NotContain(
entry => entry.Level == LogLevel.Debug && entry.Message.Contains("Still skipping"));
}

[Fact]
public async Task ExpireProposalsAsync_ShouldReturnZero_WhenNoneExpired()
{
Expand Down
Loading