Skip to content

Commit 445b2ac

Browse files
test: Add comprehensive test coverage for continuous aggregate policies
Add unit tests for previously untested components: builder validation, model extractor, annotation applier, and convention error handling. These tests cover input validation, default value handling, schema resolution, annotation application, and fluent API method chaining.
1 parent ffb5c65 commit 445b2ac

22 files changed

Lines changed: 5974 additions & 67 deletions

samples/Eftdb.Samples.Shared/Configurations/TradeAggregateConfiguration.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public void Configure(EntityTypeBuilder<TradeAggregate> builder)
2121
.Where("\"ticker\" = 'MCRS'")
2222
.MaterializedOnly()
2323
.WithRefreshPolicy(startOffset: "7 days", endOffset: "1 hour", scheduleInterval: "1 hour")
24-
.WithTimezone("UTC")
2524
.WithRefreshNewestFirst(true);
2625
}
2726
}

samples/Eftdb.Samples.Shared/Models/WeatherAggregate.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace CmdScale.EntityFrameworkCore.TimescaleDB.Example.DataAccess.Models
2323
StartOffset = "30 days",
2424
EndOffset = "1 day",
2525
ScheduleInterval = "1 hour",
26-
Timezone = "UTC",
2726
RefreshNewestFirst = true)]
2827
public class WeatherAggregate
2928
{

src/Eftdb.Design/Scaffolding/ContinuousAggregatePolicyAnnotationApplier.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ public void ApplyAnnotations(DatabaseTable table, object featureInfo)
3636
table[ContinuousAggregatePolicyAnnotations.ScheduleInterval] = info.ScheduleInterval;
3737
}
3838

39-
// Apply timezone
40-
if (!string.IsNullOrWhiteSpace(info.Timezone))
41-
{
42-
table[ContinuousAggregatePolicyAnnotations.Timezone] = info.Timezone;
43-
}
44-
4539
// Apply initial_start
4640
if (info.InitialStart.HasValue)
4741
{

src/Eftdb.Design/Scaffolding/ContinuousAggregatePolicyScaffoldingExtractor.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public sealed record ContinuousAggregatePolicyInfo(
1313
string? StartOffset,
1414
string? EndOffset,
1515
string? ScheduleInterval,
16-
string? Timezone,
1716
DateTime? InitialStart,
1817
bool? IncludeTieredData,
1918
int? BucketsPerBatch,
@@ -36,7 +35,6 @@ public sealed record ContinuousAggregatePolicyInfo(
3635
using (DbCommand command = connection.CreateCommand())
3736
{
3837
// Query continuous aggregate policies from TimescaleDB jobs table
39-
// The config column contains JSONB with start_offset, end_offset, timezone, mat_hypertable_id and other policy parameters
4038
command.CommandText = @"
4139
SELECT
4240
ca.user_view_schema,
@@ -61,7 +59,6 @@ INNER JOIN _timescaledb_catalog.continuous_agg ca
6159
// Parse the JSONB config to extract policy parameters
6260
string? startOffset = null;
6361
string? endOffset = null;
64-
string? timezone = null;
6562
bool? includeTieredData = null;
6663
int? bucketsPerBatch = null;
6764
int? maxBatchesPerExecution = null;
@@ -84,13 +81,6 @@ INNER JOIN _timescaledb_catalog.continuous_agg ca
8481
endOffset = ParseIntervalOrInteger(endOffsetElement);
8582
}
8683

87-
// Extract timezone
88-
if (root.TryGetProperty("timezone", out JsonElement timezoneElement)
89-
&& timezoneElement.ValueKind == JsonValueKind.String)
90-
{
91-
timezone = timezoneElement.GetString();
92-
}
93-
9484
// Extract include_tiered_data (optional)
9585
if (root.TryGetProperty("include_tiered_data", out JsonElement includeTieredDataElement)
9686
&& (includeTieredDataElement.ValueKind == JsonValueKind.True || includeTieredDataElement.ValueKind == JsonValueKind.False))
@@ -124,7 +114,6 @@ INNER JOIN _timescaledb_catalog.continuous_agg ca
124114
StartOffset: startOffset,
125115
EndOffset: endOffset,
126116
ScheduleInterval: scheduleInterval,
127-
Timezone: timezone,
128117
InitialStart: initialStart,
129118
IncludeTieredData: includeTieredData,
130119
BucketsPerBatch: bucketsPerBatch,

src/Eftdb/Configuration/ContinuousAggregatePolicy/ContinuousAggregateBuilderPolicyExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public static class ContinuousAggregateBuilderPolicyExtensions
2121
/// <code>
2222
/// builder.IsContinuousAggregate&lt;HourlyMetric, Metric&gt;("hourly_metrics", "1 hour", x => x.Timestamp)
2323
/// .WithRefreshPolicy(startOffset: "1 month", endOffset: "1 hour", scheduleInterval: "1 hour")
24-
/// .WithTimezone("UTC")
2524
/// .WithRefreshNewestFirst(true);
2625
/// </code>
2726
/// </example>

src/Eftdb/Configuration/ContinuousAggregatePolicy/ContinuousAggregatePolicyAnnotations.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public static class ContinuousAggregatePolicyAnnotations
3838
/// </summary>
3939
public const string IfNotExists = "TimescaleDB:ContinuousAggregatePolicy:IfNotExists";
4040

41-
/// <summary>
42-
/// Timezone to mitigate daylight savings alignment shifts. Stored as string (e.g., "UTC", "America/New_York").
43-
/// </summary>
44-
public const string Timezone = "TimescaleDB:ContinuousAggregatePolicy:Timezone";
45-
4641
/// <summary>
4742
/// Override tiered read settings. Stored as nullable bool.
4843
/// </summary>

src/Eftdb/Configuration/ContinuousAggregatePolicy/ContinuousAggregatePolicyAttribute.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ public sealed class ContinuousAggregatePolicyAttribute : Attribute
7070
/// </summary>
7171
public bool IfNotExists { get; set; } = false;
7272

73-
/// <summary>
74-
/// Gets or sets the timezone to mitigate daylight savings alignment shifts.
75-
/// </summary>
76-
/// <example>
77-
/// "UTC", "America/New_York", "Europe/London"
78-
/// </example>
79-
public string? Timezone { get; set; }
80-
8173
/// <summary>
8274
/// Gets or sets a value indicating whether to override tiered read settings.
8375
/// NULL means use default behavior.

src/Eftdb/Configuration/ContinuousAggregatePolicy/ContinuousAggregatePolicyBuilder.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ public ContinuousAggregatePolicyBuilder<TEntity, TSourceEntity> WithIfNotExists(
5151
return this;
5252
}
5353

54-
/// <summary>
55-
/// Sets the timezone for the continuous aggregate refresh policy to mitigate daylight savings alignment shifts.
56-
/// </summary>
57-
/// <param name="timezone">The timezone (e.g., "UTC", "America/New_York", "Europe/London").</param>
58-
/// <returns>The builder for method chaining.</returns>
59-
public ContinuousAggregatePolicyBuilder<TEntity, TSourceEntity> WithTimezone(string timezone)
60-
{
61-
if (string.IsNullOrWhiteSpace(timezone))
62-
throw new ArgumentException("Timezone must be provided.", nameof(timezone));
63-
64-
EntityTypeBuilder.HasAnnotation(ContinuousAggregatePolicyAnnotations.Timezone, timezone);
65-
return this;
66-
}
67-
6854
/// <summary>
6955
/// Configures whether to override tiered read settings for the continuous aggregate refresh policy.
7056
/// </summary>

src/Eftdb/Configuration/ContinuousAggregatePolicy/ContinuousAggregatePolicyConvention.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ public void ProcessEntityTypeAdded(IConventionEntityTypeBuilder entityTypeBuilde
6060
if (attribute.IfNotExists)
6161
entityTypeBuilder.HasAnnotation(ContinuousAggregatePolicyAnnotations.IfNotExists, attribute.IfNotExists);
6262

63-
// Apply timezone
64-
if (!string.IsNullOrWhiteSpace(attribute.Timezone))
65-
entityTypeBuilder.HasAnnotation(ContinuousAggregatePolicyAnnotations.Timezone, attribute.Timezone);
66-
6763
// Apply include_tiered_data if explicitly set
6864
if (attribute.IncludeTieredData.HasValue)
6965
entityTypeBuilder.HasAnnotation(ContinuousAggregatePolicyAnnotations.IncludeTieredData, attribute.IncludeTieredData.Value);

src/Eftdb/Generators/ContinuousAggregatePolicyOperationGenerator.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ public List<string> Generate(AddContinuousAggregatePolicyOperation operation)
8282
arguments.Add($"if_not_exists => {operation.IfNotExists.ToString().ToLowerInvariant()}");
8383
}
8484

85-
if (!string.IsNullOrWhiteSpace(operation.Timezone))
86-
{
87-
arguments.Add($"timezone => '{operation.Timezone}'");
88-
}
89-
9085
if (operation.IncludeTieredData.HasValue)
9186
{
9287
arguments.Add($"include_tiered_data => {operation.IncludeTieredData.Value.ToString().ToLowerInvariant()}");

0 commit comments

Comments
 (0)