blocked 4

This commit is contained in:
StellaOps Bot
2025-11-23 17:18:33 +02:00
parent c3ce1ebc25
commit fc99092dec
16 changed files with 88 additions and 25 deletions

View File

@@ -17,6 +17,7 @@ public class ProjectionEndpointTests : IClassFixture<WebApplicationFactory<Progr
public ProjectionEndpointTests(WebApplicationFactory<Program> factory)
{
var contentRoot = ResolveContentRoot();
_factory = factory.WithWebHostBuilder(builder =>
{
var fixturePath = GetProjectionFixturePath();
@@ -39,6 +40,8 @@ public class ProjectionEndpointTests : IClassFixture<WebApplicationFactory<Progr
services.RemoveAll<IComponentLookupRepository>();
services.AddSingleton<IComponentLookupRepository, InMemoryComponentLookupRepository>();
});
builder.UseSetting(WebHostDefaults.ContentRootKey, contentRoot);
});
}
@@ -77,10 +80,24 @@ public class ProjectionEndpointTests : IClassFixture<WebApplicationFactory<Progr
private static string GetProjectionFixturePath()
{
// Resolve docs/modules/sbomservice/fixtures/lnm-v1/projections.json relative to test bin directory.
var baseDir = AppContext.BaseDirectory;
var candidate = Path.GetFullPath(Path.Combine(
baseDir,
"../../../../../../docs/modules/sbomservice/fixtures/lnm-v1/projections.json"));
return candidate;
var baseDir = ResolveContentRoot();
return Path.Combine(baseDir, "docs", "modules", "sbomservice", "fixtures", "lnm-v1", "projections.json");
}
private static string ResolveContentRoot()
{
// Walk up from bin folder to repo root (containing docs/).
var dir = AppContext.BaseDirectory;
for (var i = 0; i < 6; i++)
{
var candidate = Path.GetFullPath(Path.Combine(dir, ".."));
if (Directory.Exists(Path.Combine(candidate, "docs")) &&
Directory.Exists(Path.Combine(candidate, "src")))
{
return candidate;
}
dir = candidate;
}
return AppContext.BaseDirectory;
}
}