stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using StellaOps.ReachGraph.Schema;
|
||||
|
||||
namespace StellaOps.ReachGraph.Cache.Tests;
|
||||
|
||||
internal static class ReachGraphValkeyCacheTestData
|
||||
{
|
||||
public static ReachGraphMinimal CreateGraph(string digest)
|
||||
{
|
||||
return new ReachGraphMinimal
|
||||
{
|
||||
Artifact = new ReachGraphArtifact(
|
||||
"svc.payments",
|
||||
digest,
|
||||
ImmutableArray.Create("linux/amd64")),
|
||||
Scope = new ReachGraphScope(
|
||||
ImmutableArray.Create("/app/bin/svc"),
|
||||
ImmutableArray.Create("prod")),
|
||||
Nodes = ImmutableArray.Create(new ReachGraphNode
|
||||
{
|
||||
Id = "node-1",
|
||||
Kind = ReachGraphNodeKind.Package,
|
||||
Ref = "pkg:npm/lodash@4.17.21",
|
||||
IsEntrypoint = true
|
||||
}),
|
||||
Edges = ImmutableArray.Create(new ReachGraphEdge
|
||||
{
|
||||
From = "node-1",
|
||||
To = "node-1",
|
||||
Why = new EdgeExplanation
|
||||
{
|
||||
Type = EdgeExplanationType.Import,
|
||||
Confidence = 1.0
|
||||
}
|
||||
}),
|
||||
Provenance = new ReachGraphProvenance
|
||||
{
|
||||
Inputs = new ReachGraphInputs
|
||||
{
|
||||
Sbom = "sha256:sbom"
|
||||
},
|
||||
ComputedAt = new DateTimeOffset(2026, 1, 2, 3, 4, 5, TimeSpan.Zero),
|
||||
Analyzer = new ReachGraphAnalyzer("reach-graph", "1.0.0", "sha256:tool")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static byte[] Compress(byte[] data)
|
||||
{
|
||||
using var output = new MemoryStream();
|
||||
using (var gzip = new GZipStream(output, CompressionLevel.Fastest, leaveOpen: true))
|
||||
{
|
||||
gzip.Write(data);
|
||||
}
|
||||
return output.ToArray();
|
||||
}
|
||||
|
||||
public static byte[] Decompress(byte[] compressed)
|
||||
{
|
||||
using var input = new MemoryStream(compressed);
|
||||
using var gzip = new GZipStream(input, CompressionMode.Decompress);
|
||||
using var output = new MemoryStream();
|
||||
gzip.CopyTo(output);
|
||||
return output.ToArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user