Add unit tests for KubernetesCluster, Tenant, ServiceInstance, and RegisterClusterHandler
- 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.
This commit is contained in:
26
src/EntKube.SharedKernel/Contracts/ApiResponse.cs
Normal file
26
src/EntKube.SharedKernel/Contracts/ApiResponse.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace EntKube.SharedKernel.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Standard API response envelope used by all EntKube microservices.
|
||||
/// Every HTTP response wraps its payload in this structure so clients
|
||||
/// always know where to find the data, error messages, and metadata.
|
||||
/// </summary>
|
||||
public record ApiResponse<T>
|
||||
{
|
||||
public bool Success { get; init; }
|
||||
public T? Data { get; init; }
|
||||
public string? Error { get; init; }
|
||||
public DateTimeOffset Timestamp { get; init; } = DateTimeOffset.UtcNow;
|
||||
|
||||
public static ApiResponse<T> Ok(T data) => new()
|
||||
{
|
||||
Success = true,
|
||||
Data = data
|
||||
};
|
||||
|
||||
public static ApiResponse<T> Fail(string error) => new()
|
||||
{
|
||||
Success = false,
|
||||
Error = error
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user