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,71 @@
using EntKube.Provisioning.Domain;
using EntKube.Provisioning.Features.Apps.RemoveAppEnvironment;
using EntKube.Provisioning.Infrastructure;
using EntKube.SharedKernel.Domain;
using FluentAssertions;
namespace EntKube.Provisioning.Tests.Features;
public class RemoveAppEnvironmentHandlerTests
{
private readonly InMemoryAppRepository repository;
private readonly RemoveAppEnvironmentHandler handler;
public RemoveAppEnvironmentHandlerTests()
{
repository = new InMemoryAppRepository();
handler = new RemoveAppEnvironmentHandler(repository);
}
[Fact]
public async Task HandleAsync_ExistingEnvironment_RemovesSuccessfully()
{
// Arrange — An app with one environment.
App app = App.Create(Guid.NewGuid(), Guid.NewGuid(), "API", "api", AppType.Deployment);
Guid envId = Guid.NewGuid();
app.AddEnvironment(envId, Guid.NewGuid(), "api-dev");
await repository.AddAsync(app);
// Act
Result result = await handler.HandleAsync(new RemoveAppEnvironmentRequest(app.Id, envId));
// Assert — The environment should be removed.
result.IsSuccess.Should().BeTrue();
App? updated = await repository.GetByIdAsync(app.Id);
updated!.Environments.Should().BeEmpty();
}
[Fact]
public async Task HandleAsync_NonexistentApp_ReturnsFailure()
{
// Act
Result result = await handler.HandleAsync(new RemoveAppEnvironmentRequest(Guid.NewGuid(), Guid.NewGuid()));
// Assert
result.IsFailure.Should().BeTrue();
result.Error.Should().Contain("not found");
}
[Fact]
public async Task HandleAsync_NonexistentEnvironment_ReturnsFailure()
{
// Arrange — An app with no environments.
App app = App.Create(Guid.NewGuid(), Guid.NewGuid(), "API", "api", AppType.Deployment);
await repository.AddAsync(app);
// Act
Result result = await handler.HandleAsync(new RemoveAppEnvironmentRequest(app.Id, Guid.NewGuid()));
// Assert
result.IsFailure.Should().BeTrue();
result.Error.Should().Contain("not found");
}
}