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
@@ -1,4 +1,5 @@
using FluentAssertions;
using Microsoft.Extensions.Logging;
using Moq;
using Taskdeck.Application.DTOs;
using Taskdeck.Application.Interfaces;
Expand All @@ -8,6 +9,7 @@
using Taskdeck.Domain.Entities;
using Taskdeck.Domain.Enums;
using Taskdeck.Domain.Exceptions;
using Taskdeck.Tests.Support;
using Xunit;

namespace Taskdeck.Application.Tests.Services;
Expand Down Expand Up @@ -2059,6 +2061,50 @@ public async Task MarkAsFailedAsync_ShouldReturnSuccess_WhenApproved()

#region ExpireProposalsAsync Tests

[Fact]
public async Task ExpireProposalsAsync_ShouldKeepSkipTransitionStatePerServiceInstance()
{
var logger = new InMemoryLogger<AutomationProposalService>();
var firstScopeService = new AutomationProposalService(
_unitOfWorkMock.Object,
_notificationServiceMock.Object,
provenanceRepository: null,
policyEngine: null,
logger: logger);
var secondScopeService = new AutomationProposalService(
_unitOfWorkMock.Object,
_notificationServiceMock.Object,
provenanceRepository: null,
policyEngine: null,
logger: logger);

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

await firstScopeService.ExpireProposalsAsync();
await firstScopeService.ExpireProposalsAsync();
await secondScopeService.ExpireProposalsAsync();

logger.Entries.Count(
entry => entry.Level == LogLevel.Information
&& entry.Message.Contains("Skipped expiring")
&& entry.Message.Contains("2"))
.Should().Be(2);
logger.Entries.Should().ContainSingle(
entry => entry.Level == LogLevel.Debug
&& entry.Message.Contains("Still skipping")
&& entry.Message.Contains("2"));
}

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