- Implement tests for KubernetesCluster including registration, connectivity status, and error handling. - Create tests for Tenant creation, member management, and status changes. - Add tests for ServiceInstance provisioning and state management. - Introduce RegisterClusterHandler tests to validate registration requests and error scenarios. - Set up project files for new test projects with necessary dependencies.
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using EntKube.Provisioning.Domain;
|
|
|
|
namespace EntKube.Provisioning.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// In-memory implementation of the service instance repository for local development.
|
|
/// Production will use EF Core with PostgreSQL.
|
|
/// </summary>
|
|
public class InMemoryServiceInstanceRepository : IServiceInstanceRepository
|
|
{
|
|
private readonly List<ServiceInstance> instances = new();
|
|
|
|
public Task<ServiceInstance?> GetByIdAsync(Guid id, CancellationToken ct = default)
|
|
{
|
|
ServiceInstance? instance = instances.FirstOrDefault(i => i.Id == id);
|
|
return Task.FromResult(instance);
|
|
}
|
|
|
|
public Task<IReadOnlyList<ServiceInstance>> GetByClusterIdAsync(Guid clusterId, CancellationToken ct = default)
|
|
{
|
|
IReadOnlyList<ServiceInstance> result = instances.Where(i => i.ClusterId == clusterId).ToList().AsReadOnly();
|
|
return Task.FromResult(result);
|
|
}
|
|
|
|
public Task<IReadOnlyList<ServiceInstance>> GetAllAsync(CancellationToken ct = default)
|
|
{
|
|
IReadOnlyList<ServiceInstance> result = instances.AsReadOnly();
|
|
return Task.FromResult(result);
|
|
}
|
|
|
|
public Task AddAsync(ServiceInstance instance, CancellationToken ct = default)
|
|
{
|
|
instances.Add(instance);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task UpdateAsync(ServiceInstance instance, CancellationToken ct = default)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|