This commit is contained in:
StellaOps Bot
2025-11-24 07:49:18 +02:00
parent bb709b643e
commit 5970f0d9bd
16 changed files with 690 additions and 14 deletions

View File

@@ -0,0 +1,35 @@
using System.Threading.Tasks;
using StellaOps.Policy.Engine.Overlay;
using StellaOps.Policy.Engine.Services;
using StellaOps.Policy.Engine.Streaming;
namespace StellaOps.Policy.Engine.Tests;
public sealed class OverlayProjectionServiceTests
{
[Fact]
public async Task BuildSnapshotAsync_ProducesHeaderAndSortedProjections()
{
var service = new OverlayProjectionService(new PolicyEvaluationService(), TimeProvider.System);
var request = new PathScopeSimulationRequest(
SchemaVersion: "1.0.0",
Tenant: "acme",
BasePolicyRef: "policy://acme/main@sha256:1",
CandidatePolicyRef: "policy://acme/feat@sha256:2",
Subject: new PathScopeSubject("pkg:npm/lodash@4.17.21", null, "lib.js", null),
Targets: new[]
{
new PathScopeTarget("b/file.js", "b/", "prefix", 0.5, null, null, null, "e2", null, null),
new PathScopeTarget("a/file.js", "a/", "prefix", 0.9, null, null, null, "e1", null, null)
},
Options: new SimulationOptions("path,finding,verdict", 100, IncludeTrace: true, Deterministic: true));
var lines = await service.BuildSnapshotAsync(request);
Assert.Equal(3, lines.Count); // header + 2 projections
Assert.Contains("overlay-projection-v1", lines[0]);
Assert.Contains("\"filePath\":\"a/file.js\"", lines[1]);
Assert.Contains("\"filePath\":\"b/file.js\"", lines[2]);
}
}