Skip to content

Commit f76aa71

Browse files
Add CreatedDate property to licensing endpoint mappings and tests
1 parent 9046ad0 commit f76aa71

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/ServiceControl.Migration.AcceptanceTests/LicensingEndpointsMigrationTests.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace ServiceControl.Migration.AcceptanceTests;
22

3+
using System;
34
using System.Collections.Generic;
45
using System.Linq;
56
using System.Threading.Tasks;
@@ -20,7 +21,8 @@ await SeedThroughputSource(new Endpoint("Sales.Orders", ThroughputSource.Broker)
2021
SanitizedName = "Sales_Orders",
2122
UserIndicator = "Sales team",
2223
Scope = "Sales",
23-
EndpointIndicators = [EndpointIndicator.PlatformEndpoint.ToString()]
24+
EndpointIndicators = [EndpointIndicator.PlatformEndpoint.ToString()],
25+
CreatedDate = new DateTime(2026, 3, 4, 5, 6, 7, DateTimeKind.Utc)
2426
});
2527

2628
await CopyCategory("LicensingEndpoints");
@@ -34,6 +36,7 @@ await SeedThroughputSource(new Endpoint("Sales.Orders", ThroughputSource.Broker)
3436
Assert.That(fromTarget, Is.Not.Null);
3537
Assert.That(fromTarget!.UserIndicator, Is.EqualTo("Sales team"));
3638
Assert.That(fromTarget.Scope, Is.EqualTo("Sales"));
39+
Assert.That(fromTarget.CreatedDate, Is.EqualTo(new DateTime(2026, 3, 4, 5, 6, 7, DateTimeKind.Utc)), "the decommissioned endpoint sweep removes an endpoint with no throughput once it is a day old, so a lost date makes a new endpoint eligible at once");
3740
Assert.That(row.SanitizedName, Is.EqualTo("Sales_Orders"));
3841
Assert.That(row.NormalizedSanitizedName, Is.EqualTo("sales_orders"), "GetEndpointThroughputByQueueName matches on this column, so an unnormalised value hides a migrated endpoint's throughput from the licensing report");
3942
Assert.That(fromTarget.EndpointIndicators, Is.EqualTo(new[] { EndpointIndicator.PlatformEndpoint.ToString() }), "the indicators column holds what EF itself writes: JSON on SQL Server, a text[] on PostgreSQL");

‎src/ServiceControl.Migration.AcceptanceTests/MigrationAcceptanceTest.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ protected async Task SeedThroughputSource(Endpoint endpoint)
178178
endpoint.SanitizedName,
179179
EndpointIndicators = endpoint.EndpointIndicators ?? [],
180180
UserIndicator = endpoint.UserIndicator ?? string.Empty,
181-
Scope = endpoint.Scope ?? string.Empty
181+
Scope = endpoint.Scope ?? string.Empty,
182+
endpoint.CreatedDate
182183
};
183184

184185
using var session = SourceStore.OpenAsyncSession(Source.ThroughputDatabase);

‎src/ServiceControl.Persistence.EFCore/DataMigration/LicensingEndpointRowMapper.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static LicensingEndpointEntity Map(Endpoint endpoint)
2323
NormalizedSanitizedName = LicensingDataStore.Normalize(sanitizedName),
2424
UserIndicator = endpoint.UserIndicator ?? string.Empty,
2525
Scope = endpoint.Scope,
26+
CreatedDate = endpoint.CreatedDate ?? DateTime.MinValue,
2627
EndpointIndicators = endpoint.EndpointIndicators?.ToList() ?? []
2728
};
2829
}

‎src/ServiceControl.Persistence.Tests/EFCore/Migration/LicensingMigrationMapperCoverageTests.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public async Task The_endpoint_mapper_sets_every_mapped_property()
2020
SanitizedName = "Sales.Orders",
2121
EndpointIndicators = [EndpointIndicator.PlatformEndpoint.ToString()],
2222
UserIndicator = "Sales team",
23-
Scope = "Sales"
23+
Scope = "Sales",
24+
CreatedDate = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc)
2425
};
2526

2627
MigrationEntityCoverage.AssertEveryMappedPropertyIsSet(await Model(), LicensingEndpointRowMapper.Map(endpoint));

0 commit comments

Comments
 (0)