too much for one commit

This commit is contained in:
Nils Blomgren
2026-05-13 14:01:32 +02:00
parent a96dd33039
commit 328d494530
394 changed files with 98104 additions and 78 deletions

View File

@@ -0,0 +1,64 @@
using EntKube.Provisioning.Domain;
using EntKube.Provisioning.Features.DecommissionService;
using EntKube.Provisioning.Infrastructure;
using EntKube.SharedKernel.Domain;
using FluentAssertions;
namespace EntKube.Provisioning.Tests.Features;
public class DecommissionServiceHandlerTests
{
private readonly DecommissionServiceHandler handler;
private readonly InMemoryServiceInstanceRepository repository;
public DecommissionServiceHandlerTests()
{
repository = new InMemoryServiceInstanceRepository();
handler = new DecommissionServiceHandler(repository);
}
[Fact]
public async Task HandleAsync_WithRunningService_SetsDesiredStateToDecommissioned()
{
// Arrange — A running service exists in the repository.
ServiceInstance instance = ServiceInstance.Provision(
Guid.NewGuid(),
ServiceType.MinIO,
"tenant-storage",
"minio-system",
Guid.NewGuid());
instance.MarkRunning();
await repository.AddAsync(instance);
// Act — Request decommission.
Result result = await handler.HandleAsync(instance.Id);
// Assert — The desired state should be Decommissioned.
result.IsSuccess.Should().BeTrue();
ServiceInstance? updated = await repository.GetByIdAsync(instance.Id);
updated.Should().NotBeNull();
updated!.DesiredState.Should().Be(ServiceState.Decommissioned);
}
[Fact]
public async Task HandleAsync_WithNonExistentId_ReturnsFailure()
{
// Arrange — An ID that doesn't exist.
Guid unknownId = Guid.NewGuid();
// Act
Result result = await handler.HandleAsync(unknownId);
// Assert
result.IsFailure.Should().BeTrue();
result.Error.Should().Contain("not found");
}
}