Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -12,6 +12,7 @@ using Microsoft.Extensions.Options;
|
||||
using StellaOps.Scanner.Reachability.Cache;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Scanner.Reachability.Tests;
|
||||
|
||||
public sealed class PrReachabilityGateTests
|
||||
@@ -26,7 +27,8 @@ public sealed class PrReachabilityGateTests
|
||||
_gate = new PrReachabilityGate(optionsMonitor, NullLogger<PrReachabilityGate>.Instance);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_NoFlips_ReturnsPass()
|
||||
{
|
||||
// Arrange
|
||||
@@ -42,7 +44,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Decision.MitigatedCount.Should().Be(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_NewReachable_ReturnsBlock()
|
||||
{
|
||||
// Arrange
|
||||
@@ -71,7 +74,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Decision.BlockingFlips.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_OnlyMitigated_ReturnsPass()
|
||||
{
|
||||
// Arrange
|
||||
@@ -99,7 +103,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Decision.MitigatedCount.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_GateDisabled_AlwaysPasses()
|
||||
{
|
||||
// Arrange
|
||||
@@ -126,7 +131,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Reason.Should().Be("PR gate is disabled");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_LowConfidence_Excluded()
|
||||
{
|
||||
// Arrange
|
||||
@@ -155,7 +161,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Decision.BlockingFlips.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_MaxNewReachableThreshold_AllowsUnderThreshold()
|
||||
{
|
||||
// Arrange
|
||||
@@ -189,7 +196,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Passed.Should().BeTrue(); // 2 == threshold, so should pass
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_MaxNewReachableThreshold_BlocksOverThreshold()
|
||||
{
|
||||
// Arrange
|
||||
@@ -223,7 +231,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Passed.Should().BeFalse(); // 2 > 1, so should block
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_Annotations_GeneratedForBlockingFlips()
|
||||
{
|
||||
// Arrange
|
||||
@@ -257,7 +266,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Annotations[0].StartLine.Should().Be(42);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_AnnotationsDisabled_NoAnnotations()
|
||||
{
|
||||
// Arrange
|
||||
@@ -283,7 +293,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.Annotations.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void EvaluateFlips_SummaryMarkdown_Generated()
|
||||
{
|
||||
// Arrange
|
||||
@@ -321,7 +332,8 @@ public sealed class PrReachabilityGateTests
|
||||
result.SummaryMarkdown.Should().Contain("Mitigated paths");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Evaluate_NullStateFlips_ReturnsPass()
|
||||
{
|
||||
// Arrange
|
||||
@@ -344,7 +356,8 @@ public sealed class PrReachabilityGateTests
|
||||
gateResult.Reason.Should().Be("No state flip detection performed");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Evaluate_WithStateFlips_DelegatesCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user