1010using Elastic . Documentation . Configuration ;
1111using Elastic . Documentation . Configuration . Assembler ;
1212using Elastic . Documentation . Diagnostics ;
13+ using Elastic . Documentation . Tooling . Diagnostics ;
1314using FakeItEasy ;
1415using FluentAssertions ;
1516using Microsoft . Extensions . Logging ;
@@ -62,7 +63,7 @@ public async Task TestPlan()
6263 var planStrategy = new AwsS3SyncPlanStrategy ( new LoggerFactory ( ) , mockS3Client , "fake" , context ) ;
6364
6465 // Act
65- var plan = await planStrategy . Plan ( ctx : Cancel . None ) ;
66+ var plan = await planStrategy . Plan ( null , Cancel . None ) ;
6667
6768 // Assert
6869
@@ -108,7 +109,7 @@ public async Task ValidateAdditionsPlan(
108109 bool valid
109110 )
110111 {
111- var ( planStrategy , plan ) = await SetupS3SyncContextSetup ( localFiles , remoteFiles ) ;
112+ var ( validator , _ , plan ) = await SetupS3SyncContextSetup ( localFiles , remoteFiles , deleteThreshold ) ;
112113
113114 // Assert
114115
@@ -118,7 +119,7 @@ bool valid
118119 plan . AddRequests . Count . Should ( ) . Be ( totalFilesToAdd ) ;
119120 plan . DeleteRequests . Count . Should ( ) . Be ( totalFilesToRemove ) ;
120121
121- var validationResult = planStrategy . Validate ( plan , deleteThreshold ) ;
122+ var validationResult = validator . Validate ( plan ) ;
122123 if ( plan . TotalSyncRequests <= 100 )
123124 validationResult . DeleteThreshold . Should ( ) . Be ( Math . Max ( deleteThreshold , 0.8f ) ) ;
124125 else if ( plan . TotalSyncRequests <= 1000 )
@@ -146,7 +147,7 @@ public async Task ValidateUpdatesPlan(
146147 bool valid
147148 )
148149 {
149- var ( planStrategy , plan ) = await SetupS3SyncContextSetup ( localFiles , remoteFiles , "different-etag" ) ;
150+ var ( validator , _ , plan ) = await SetupS3SyncContextSetup ( localFiles , remoteFiles , deleteThreshold , "different-etag" ) ;
150151
151152 // Assert
152153
@@ -156,7 +157,7 @@ bool valid
156157 plan . UpdateRequests . Count . Should ( ) . Be ( totalFilesToUpdate ) ;
157158 plan . DeleteRequests . Count . Should ( ) . Be ( totalFilesToRemove ) ;
158159
159- var validationResult = planStrategy . Validate ( plan , deleteThreshold ) ;
160+ var validationResult = validator . Validate ( plan ) ;
160161 if ( plan . TotalSyncRequests <= 100 )
161162 validationResult . DeleteThreshold . Should ( ) . Be ( Math . Max ( deleteThreshold , 0.8f ) ) ;
162163 else if ( plan . TotalSyncRequests <= 1000 )
@@ -165,8 +166,8 @@ bool valid
165166 validationResult . Valid . Should ( ) . Be ( valid , $ "Delete ratio is { validationResult . DeleteRatio } when maximum is { validationResult . DeleteThreshold } ") ;
166167 }
167168
168- private static async Task < ( AwsS3SyncPlanStrategy planStrategy , SyncPlan plan ) > SetupS3SyncContextSetup (
169- int localFiles , int remoteFiles , string etag = "etag" )
169+ private static async Task < ( DocsSyncPlanValidator validator , AwsS3SyncPlanStrategy planStrategy , SyncPlan plan ) > SetupS3SyncContextSetup (
170+ int localFiles , int remoteFiles , float ? deleteThreshold = null , string etag = "etag" )
170171 {
171172 // Arrange
172173 IReadOnlyCollection < IDiagnosticsOutput > diagnosticsOutputs = [ ] ;
@@ -204,8 +205,9 @@ bool valid
204205 var planStrategy = new AwsS3SyncPlanStrategy ( new LoggerFactory ( ) , mockS3Client , "fake" , context , mockEtagCalculator ) ;
205206
206207 // Act
207- var plan = await planStrategy . Plan ( ctx : Cancel . None ) ;
208- return ( planStrategy , plan ) ;
208+ var plan = await planStrategy . Plan ( deleteThreshold , Cancel . None ) ;
209+ var validator = new DocsSyncPlanValidator ( new LoggerFactory ( ) ) ;
210+ return ( validator , planStrategy , plan ) ;
209211 }
210212
211213 [ Fact ]
@@ -233,6 +235,7 @@ public async Task TestApply()
233235 var context = new AssembleContext ( config , configurationContext , "dev" , collector , fileSystem , fileSystem , null , checkoutDirectory ) ;
234236 var plan = new SyncPlan
235237 {
238+ DeleteThresholdDefault = null ,
236239 TotalRemoteFiles = 0 ,
237240 TotalSourceFiles = 5 ,
238241 TotalSyncRequests = 6 ,
0 commit comments