diff --git a/src/K8sOperator.NET/Models/CustomResource.cs b/src/K8sOperator.NET/Models/CustomResource.cs index 6ea901b..3c79cdc 100644 --- a/src/K8sOperator.NET/Models/CustomResource.cs +++ b/src/K8sOperator.NET/Models/CustomResource.cs @@ -35,13 +35,13 @@ public abstract class CustomResource : CustomResource, ISpec /// /// The type of the specification. /// The type of the status. -public abstract class CustomResource : CustomResource, IStatus +public abstract class CustomResource : CustomResource, IStatus where TSpec : new() - where TStatus : new() + where TStatus : class { /// /// Gets or sets the status for the custom resource. /// [JsonPropertyName("status")] - public TStatus Status { get; set; } = new(); + public TStatus? Status { get; set; } } diff --git a/test/K8sOperator.NET.Tests/ControllerTests.cs b/test/K8sOperator.NET.Tests/ControllerTests.cs index dbe9bb2..e37dc09 100644 --- a/test/K8sOperator.NET.Tests/ControllerTests.cs +++ b/test/K8sOperator.NET.Tests/ControllerTests.cs @@ -1,6 +1,4 @@ -using K8sOperator.NET.Models; - -namespace K8sOperator.NET.Tests; +namespace K8sOperator.NET.Tests; public class ControllerTests { @@ -79,8 +77,9 @@ public async Task Overridden_AddOrModifyAsync_Should_Call_CustomImplementation() // Act await derivedController.AddOrModifyAsync(resource, CancellationToken.None); - // Assert - resource.Status.Status.Should().Be("Changed"); + + resource.Status.Should().NotBeNull(); + resource.Status?.Status.Should().Be("Changed"); } // You can also extend these tests for DeleteAsync, FinalizeAsync, BookmarkAsync, and ErrorAsync