Skip to content

Commit e5e5bc3

Browse files
committed
fix tests compilation
1 parent 64bae54 commit e5e5bc3

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/tooling/docs-assembler/Deploying/AwsS3SyncPlanStrategy.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ public class AwsS3SyncPlanStrategy(
8282
)
8383
: IDocsSyncPlanStrategy
8484
{
85-
private readonly ILogger<AwsS3SyncPlanStrategy> _logger = logFactory.CreateLogger<AwsS3SyncPlanStrategy>();
86-
8785
private readonly IS3EtagCalculator _s3EtagCalculator = calculator ?? new S3EtagCalculator(logFactory, context.ReadFileSystem);
8886

8987
private bool IsSymlink(string path)
@@ -92,7 +90,7 @@ private bool IsSymlink(string path)
9290
return fileInfo.LinkTarget != null;
9391
}
9492

95-
public async Task<SyncPlan> Plan(float? deleteThreshold = null, Cancel ctx = default)
93+
public async Task<SyncPlan> Plan(float? deleteThreshold, Cancel ctx = default)
9694
{
9795
var remoteObjects = await ListObjects(ctx);
9896
var localObjects = context.OutputDirectory.GetFiles("*", SearchOption.AllDirectories)

src/tooling/docs-assembler/Deploying/DocsSync.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Documentation.Assembler.Deploying;
99

1010
public interface IDocsSyncPlanStrategy
1111
{
12-
Task<SyncPlan> Plan(float? deleteThreshold = null, Cancel ctx = default);
12+
Task<SyncPlan> Plan(float? deleteThreshold, Cancel ctx = default);
1313

1414
}
1515
public record PlanValidationResult(bool Valid, float DeleteRatio, float DeleteThreshold);

tests/docs-assembler.Tests/src/docs-assembler.Tests/DocsSyncTests.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Elastic.Documentation.Configuration;
1111
using Elastic.Documentation.Configuration.Assembler;
1212
using Elastic.Documentation.Diagnostics;
13+
using Elastic.Documentation.Tooling.Diagnostics;
1314
using FakeItEasy;
1415
using FluentAssertions;
1516
using 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

Comments
 (0)