Skip to content

Commit 94f47d5

Browse files
authored
Allow Nullable Status (#50)
1 parent 2a104eb commit 94f47d5

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/K8sOperator.NET/Models/CustomResource.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ public abstract class CustomResource<TSpec> : CustomResource, ISpec<TSpec>
3535
/// </summary>
3636
/// <typeparam name="TSpec">The type of the specification.</typeparam>
3737
/// <typeparam name="TStatus">The type of the status.</typeparam>
38-
public abstract class CustomResource<TSpec, TStatus> : CustomResource<TSpec>, IStatus<TStatus>
38+
public abstract class CustomResource<TSpec, TStatus> : CustomResource<TSpec>, IStatus<TStatus?>
3939
where TSpec : new()
40-
where TStatus : new()
40+
where TStatus : class
4141
{
4242
/// <summary>
4343
/// Gets or sets the status for the custom resource.
4444
/// </summary>
4545
[JsonPropertyName("status")]
46-
public TStatus Status { get; set; } = new();
46+
public TStatus? Status { get; set; }
4747
}

test/K8sOperator.NET.Tests/ControllerTests.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using K8sOperator.NET.Models;
2-
3-
namespace K8sOperator.NET.Tests;
1+
namespace K8sOperator.NET.Tests;
42

53
public class ControllerTests
64
{
@@ -79,8 +77,9 @@ public async Task Overridden_AddOrModifyAsync_Should_Call_CustomImplementation()
7977
// Act
8078
await derivedController.AddOrModifyAsync(resource, CancellationToken.None);
8179

82-
// Assert
83-
resource.Status.Status.Should().Be("Changed");
80+
81+
resource.Status.Should().NotBeNull();
82+
resource.Status?.Status.Should().Be("Changed");
8483
}
8584

8685
// You can also extend these tests for DeleteAsync, FinalizeAsync, BookmarkAsync, and ErrorAsync

0 commit comments

Comments
 (0)