Refactor code structure for improved readability and maintainability; optimize performance in key functions.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using StellaOps.Graph.Api.Contracts;
|
||||
using StellaOps.Graph.Api.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Graph.Api.Tests;
|
||||
|
||||
public sealed class LineageServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task GetLineageAsync_ReturnsSbomAndArtifactChain()
|
||||
{
|
||||
var repository = new InMemoryGraphRepository();
|
||||
var service = new InMemoryGraphLineageService(repository);
|
||||
|
||||
var request = new GraphLineageRequest
|
||||
{
|
||||
SbomDigest = "sha256:sbom-b",
|
||||
MaxDepth = 3
|
||||
};
|
||||
|
||||
var response = await service.GetLineageAsync("acme", request, CancellationToken.None);
|
||||
|
||||
Assert.Contains(response.Nodes, node => node.Id == "gn:acme:sbom:sha256:sbom-b");
|
||||
Assert.Contains(response.Nodes, node => node.Id == "gn:acme:sbom:sha256:sbom-a");
|
||||
Assert.Contains(response.Nodes, node => node.Id == "gn:acme:artifact:sha256:abc");
|
||||
Assert.Contains(response.Edges, edge => edge.Kind == "SBOM_LINEAGE_PARENT");
|
||||
Assert.Contains(response.Edges, edge => edge.Kind == "SBOM_VERSION_OF");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user