Files
git.stella-ops.org/src/Scanner/__Tests/StellaOps.Scanner.Analyzers.Lang.Deno.Tests/Observations/ObservationSerializerTests.cs
master 69c59defdc
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
feat: Implement Runtime Facts ingestion service and NDJSON reader
- Added RuntimeFactsNdjsonReader for reading NDJSON formatted runtime facts.
- Introduced IRuntimeFactsIngestionService interface and its implementation.
- Enhanced Program.cs to register new services and endpoints for runtime facts.
- Updated CallgraphIngestionService to include CAS URI in stored artifacts.
- Created RuntimeFactsValidationException for validation errors during ingestion.
- Added tests for RuntimeFactsIngestionService and RuntimeFactsNdjsonReader.
- Implemented SignalsSealedModeMonitor for compliance checks in sealed mode.
- Updated project dependencies for testing utilities.
2025-11-10 07:56:15 +02:00

29 lines
1.2 KiB
C#

using System.Collections.Immutable;
using System.Security.Cryptography;
using System.Text;
using StellaOps.Scanner.Analyzers.Lang.Deno.Internal;
using StellaOps.Scanner.Analyzers.Lang.Deno.Internal.Observations;
namespace StellaOps.Scanner.Analyzers.Lang.Deno.Tests.Observations;
public sealed class ObservationSerializerTests
{
[Fact]
public void SerializeProducesDeterministicJson()
{
var document = new DenoObservationDocument(
ImmutableArray.Create("mod.ts"),
ImmutableArray.Create("https://example.com/deps.ts"),
ImmutableArray<DenoCapabilityRecord>.Empty,
ImmutableArray<DenoDynamicImportObservation>.Empty,
ImmutableArray<DenoLiteralFetchObservation>.Empty,
ImmutableArray.Create(new DenoObservationBundleSummary("bundle.eszip", "eszip", "mod.ts", 2, 1)));
var json = DenoObservationSerializer.Serialize(document);
var hash = DenoObservationSerializer.ComputeSha256(json);
Assert.Equal("sha256:" + Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(json))).ToLowerInvariant(), hash);
Assert.Contains("\"entrypoints\":[\"mod.ts\"]", json, StringComparison.Ordinal);
}
}