too much for one commit
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user