Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -9,5 +9,6 @@
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.Concelier.Exporter.Json/StellaOps.Concelier.Exporter.Json.csproj" />
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.Concelier.Exporter.TrivyDb/StellaOps.Concelier.Exporter.TrivyDb.csproj" />
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.Concelier.Models/StellaOps.Concelier.Models.csproj" />
|
||||
<ProjectReference Include="../../../__Libraries/StellaOps.TestKit/StellaOps.TestKit.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -2,11 +2,13 @@ using System;
|
||||
using StellaOps.Concelier.Exporter.TrivyDb;
|
||||
using StellaOps.Concelier.Storage.Exporting;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Concelier.Exporter.TrivyDb.Tests;
|
||||
|
||||
public sealed class TrivyDbExportPlannerTests
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void CreatePlan_ReturnsFullWhenStateMissing()
|
||||
{
|
||||
var planner = new TrivyDbExportPlanner();
|
||||
@@ -21,7 +23,8 @@ public sealed class TrivyDbExportPlannerTests
|
||||
Assert.Equal(manifest, plan.Manifest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void CreatePlan_ReturnsSkipWhenCursorMatches()
|
||||
{
|
||||
var planner = new TrivyDbExportPlanner();
|
||||
@@ -49,7 +52,8 @@ public sealed class TrivyDbExportPlannerTests
|
||||
Assert.Empty(plan.RemovedPaths);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void CreatePlan_ReturnsFullWhenCursorDiffers()
|
||||
{
|
||||
var planner = new TrivyDbExportPlanner();
|
||||
|
||||
@@ -17,6 +17,8 @@ using StellaOps.Concelier.Models;
|
||||
using StellaOps.Concelier.Storage.Advisories;
|
||||
using StellaOps.Concelier.Storage.Exporting;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Concelier.Exporter.TrivyDb.Tests;
|
||||
|
||||
public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
@@ -30,7 +32,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
_jsonRoot = Path.Combine(_root, "tree");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_SortsAdvisoriesByKeyDeterministically()
|
||||
{
|
||||
var advisoryB = CreateSampleAdvisory("CVE-2024-1002", "Second advisory");
|
||||
@@ -98,7 +101,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.Single(recordingBuilder.ManifestDigests);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_SmallDatasetProducesDeterministicOciLayout()
|
||||
{
|
||||
var advisories = new[]
|
||||
@@ -134,7 +138,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.Equal(TrivyDbMediaTypes.TrivyLayer, layer.GetProperty("mediaType").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ExportOptions_GetExportRoot_NormalizesRelativeRoot()
|
||||
{
|
||||
var options = new TrivyDbExportOptions
|
||||
@@ -149,7 +154,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.EndsWith(Path.Combine("exports", "trivy-test", exportId), path, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_PersistsStateAndSkipsWhenDigestUnchanged()
|
||||
{
|
||||
var advisory = CreateSampleAdvisory();
|
||||
@@ -222,7 +228,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.Empty(orasPusher.Pushes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_CreatesOfflineBundle()
|
||||
{
|
||||
var advisory = CreateSampleAdvisory();
|
||||
@@ -282,7 +289,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.Empty(orasPusher.Pushes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_WritesMirrorBundlesWhenConfigured()
|
||||
{
|
||||
var advisoryOne = CreateSampleAdvisory("CVE-2025-1001", "Mirror Advisory One");
|
||||
@@ -431,7 +439,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.Empty(orasPusher.Pushes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_SkipsOrasPushWhenDeltaPublishingDisabled()
|
||||
{
|
||||
var initial = CreateSampleAdvisory("CVE-2024-7100", "Publish toggles");
|
||||
@@ -492,7 +501,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.Empty(orasPusher.Pushes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_SkipsOfflineBundleForDeltaWhenDisabled()
|
||||
{
|
||||
var initial = CreateSampleAdvisory("CVE-2024-7200", "Offline delta toggles");
|
||||
@@ -562,7 +572,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.False(File.Exists(deltaBundlePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_ResetsBaselineWhenDeltaChainExists()
|
||||
{
|
||||
var advisory = CreateSampleAdvisory("CVE-2024-5000", "Baseline reset");
|
||||
@@ -635,7 +646,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.NotEmpty(updated.Files);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_DeltaSequencePromotesBaselineReset()
|
||||
{
|
||||
var baseline = CreateSampleAdvisory("CVE-2024-8100", "Baseline advisory");
|
||||
@@ -725,7 +737,8 @@ public sealed class TrivyDbFeedExporterTests : IDisposable
|
||||
Assert.Equal(finalExportId, state.BaseExportId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ExportAsync_DeltaReusesBaseLayerOnDisk()
|
||||
{
|
||||
var baseline = CreateSampleAdvisory("CVE-2024-8300", "Layer reuse baseline");
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||
using StellaOps.Concelier.Storage.Exporting;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Concelier.Exporter.TrivyDb.Tests;
|
||||
|
||||
public sealed class TrivyDbOciWriterTests : IDisposable
|
||||
@@ -21,7 +22,8 @@ public sealed class TrivyDbOciWriterTests : IDisposable
|
||||
_root = Directory.CreateTempSubdirectory("trivy-writer-tests").FullName;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task WriteAsync_ReusesBlobsFromBaseLayout_WhenDigestMatches()
|
||||
{
|
||||
var baseLayout = Path.Combine(_root, "base");
|
||||
|
||||
@@ -6,11 +6,13 @@ using System.Text;
|
||||
using System.Text.Json;
|
||||
using StellaOps.Concelier.Exporter.TrivyDb;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Concelier.Exporter.TrivyDb.Tests;
|
||||
|
||||
public sealed class TrivyDbPackageBuilderTests
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void BuildsOciManifestWithExpectedMediaTypes()
|
||||
{
|
||||
var metadata = Encoding.UTF8.GetBytes("{\"generatedAt\":\"2024-07-15T12:00:00Z\"}");
|
||||
@@ -56,7 +58,8 @@ public sealed class TrivyDbPackageBuilderTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ThrowsWhenMetadataMissing()
|
||||
{
|
||||
var builder = new TrivyDbPackageBuilder();
|
||||
|
||||
Reference in New Issue
Block a user