Files
jdescopingtool/NEW/tests/JdeScoping.DataSync.Tests/Configuration/PipelinesRootTests.cs
T
Joseph Doherty c814a7294b refactor(datasync): remove deprecated SyncMode and SyncModeConfig
- Delete SyncMode.cs enum file
- Remove SyncModes property from PipelineConfig
- Remove SyncModeConfig and DestinationOverride records
- Remove WithMode(SyncMode) from IEtlPipelineBuilder
- Remove BuildWithSyncModes() and related methods from EtlPipelineFactory
- Remove syncModes sections from all pipelines in pipelines.json
- Update tests to use schedules-only configuration

All pipelines now require 'schedules' format (mass/daily/hourly).
WithUpdateType(UpdateTypes) is the only way to set update type.
2026-01-07 05:16:20 -05:00

107 lines
3.4 KiB
C#

using JdeScoping.DataSync.Configuration;
using Shouldly;
namespace JdeScoping.DataSync.Tests.Configuration;
public class PipelinesRootTests
{
[Fact]
public void EffectiveScheduleDefaults_WhenNull_ReturnsDefaults()
{
var root = new PipelinesRoot(null, null, new Dictionary<string, PipelineConfig>());
var defaults = root.EffectiveScheduleDefaults;
defaults.ShouldNotBeNull();
defaults.Mass.IntervalMinutes.ShouldBe(10080);
defaults.Daily.IntervalMinutes.ShouldBe(1440);
defaults.Hourly.IntervalMinutes.ShouldBe(60);
}
[Fact]
public void EffectiveScheduleDefaults_WhenProvided_ReturnsProvided()
{
var customDefaults = new ScheduleDefaults
{
Mass = new ScheduleConfig { IntervalMinutes = 20000 }
};
var root = new PipelinesRoot(null, customDefaults, new Dictionary<string, PipelineConfig>());
var defaults = root.EffectiveScheduleDefaults;
defaults.Mass.IntervalMinutes.ShouldBe(20000);
}
[Fact]
public void EffectiveSettings_WhenNull_ReturnsDefaults()
{
var root = new PipelinesRoot(null, null, new Dictionary<string, PipelineConfig>());
var settings = root.EffectiveSettings;
settings.ShouldNotBeNull();
settings.Timezone.ShouldBe("UTC");
}
[Fact]
public void EffectiveSettings_WhenProvided_ReturnsProvided()
{
var customSettings = new PipelineSettings("America/New_York");
var root = new PipelinesRoot(customSettings, null, new Dictionary<string, PipelineConfig>());
var settings = root.EffectiveSettings;
settings.Timezone.ShouldBe("America/New_York");
}
[Fact]
public void Pipelines_WhenProvided_StoresCorrectly()
{
var pipelines = new Dictionary<string, PipelineConfig>
{
["TestTable"] = CreateMinimalPipelineConfig()
};
var root = new PipelinesRoot(null, null, pipelines);
root.Pipelines.ShouldContainKey("TestTable");
root.Pipelines["TestTable"].Destination.Table.ShouldBe("TestTable");
}
[Fact]
public void PipelineConfig_WithSchedules_ParsesCorrectly()
{
var config = new PipelineConfig(
new SourceConfig("jde", "SELECT 1", null, null),
new PipelineSchedules
{
Mass = new ScheduleConfig { PrePurge = true, ReIndex = true },
Daily = new ScheduleConfig { Enabled = true },
Hourly = new ScheduleConfig { Enabled = false }
},
null, // Transformers
new DestinationConfig("TestTable", ["Id"], null),
null,
null);
config.Schedules.ShouldNotBeNull();
config.Schedules!.Mass!.PrePurge.ShouldBeTrue();
config.Schedules!.Hourly!.Enabled.ShouldBeFalse();
}
private static PipelineConfig CreateMinimalPipelineConfig()
{
return new PipelineConfig(
new SourceConfig("lotfinder", "SELECT 1", null, null),
new PipelineSchedules
{
Mass = new ScheduleConfig { PrePurge = true, ReIndex = true },
Daily = new ScheduleConfig(),
Hourly = new ScheduleConfig()
},
null, // Transformers
new DestinationConfig("TestTable", ["Id"], null),
null,
null);
}
}