Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -9,6 +9,7 @@ using FluentAssertions;
|
||||
using StellaOps.Concelier.Merge.Identity;
|
||||
using StellaOps.Concelier.Merge.Identity.Normalizers;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Concelier.Merge.Tests;
|
||||
|
||||
/// <summary>
|
||||
@@ -26,7 +27,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
|
||||
#region Same Patch Lineage = Same Hash
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_SamePatchLineage_ProducesSameHash()
|
||||
{
|
||||
// Arrange
|
||||
@@ -56,7 +58,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
hash1.Should().Be(hash2, "same patch lineage should produce same hash");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_NoPatchLineage_ProducesSameHash()
|
||||
{
|
||||
// Arrange
|
||||
@@ -90,7 +93,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
|
||||
#region Different Patch Lineage = Different Hash
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_DifferentPatchLineage_ProducesDifferentHash()
|
||||
{
|
||||
// Arrange - Upstream fix vs distro-specific backport
|
||||
@@ -121,7 +125,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
"different patch lineage should produce different hash");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_WithVsWithoutPatchLineage_ProducesDifferentHash()
|
||||
{
|
||||
// Arrange
|
||||
@@ -152,7 +157,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
"advisory with patch lineage should differ from one without");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_DebianVsRhelBackport_ProducesDifferentHash()
|
||||
{
|
||||
// Arrange - Same CVE, different distro backports
|
||||
@@ -187,7 +193,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
|
||||
#region Patch Lineage Normalization
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData(
|
||||
"abc123def456abc123def456abc123def456abcd",
|
||||
"ABC123DEF456ABC123DEF456ABC123DEF456ABCD",
|
||||
@@ -230,7 +237,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
hash1.Should().Be(hash2, reason);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_AbbreviatedSha_DiffersFromFullSha()
|
||||
{
|
||||
// Abbreviated SHA is treated as different from a full different SHA
|
||||
@@ -265,7 +273,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
|
||||
#region Real-World Scenarios
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_GoldenCorpus_DebianBackportVsNvd()
|
||||
{
|
||||
// Golden corpus test case: CVE-2024-1234 with Debian backport
|
||||
@@ -300,7 +309,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
"NVD and Debian entries should produce different hashes due to package and version differences");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_GoldenCorpus_DistroSpecificFix()
|
||||
{
|
||||
// Golden corpus test case: Distro-specific fix different from upstream
|
||||
@@ -331,7 +341,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
"distro-specific fix should produce different hash from upstream");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_SameUpstreamBackported_ProducesSameHash()
|
||||
{
|
||||
// When two distros backport the SAME upstream patch, they should merge
|
||||
@@ -367,7 +378,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
|
||||
#region Edge Cases
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_EmptyPatchLineage_TreatedAsNull()
|
||||
{
|
||||
var emptyLineage = new MergeHashInput
|
||||
@@ -397,7 +409,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
"empty and null patch lineage should produce same hash");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_WhitespacePatchLineage_TreatedAsNull()
|
||||
{
|
||||
var whitespaceLineage = new MergeHashInput
|
||||
@@ -427,7 +440,8 @@ public sealed class MergeHashBackportDifferentiationTests
|
||||
"whitespace-only patch lineage should be treated as null");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeMergeHash_IsDeterministic()
|
||||
{
|
||||
// Verify determinism across multiple calls
|
||||
|
||||
Reference in New Issue
Block a user