39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using Xunit;
|
|
using System.Threading.Tasks;
|
|
using StellaOps.Policy.Engine.Overlay;
|
|
using StellaOps.Policy.Engine.Services;
|
|
using StellaOps.Policy.Engine.Streaming;
|
|
|
|
using StellaOps.TestKit;
|
|
namespace StellaOps.Policy.Engine.Tests;
|
|
|
|
public sealed class OverlayProjectionServiceTests
|
|
{
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[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]);
|
|
}
|
|
}
|