stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using StellaOps.TestKit;
|
||||
using StellaOps.Testing.Determinism;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Testing.Determinism.Tests;
|
||||
|
||||
public sealed partial class DeterminismSummaryTests
|
||||
{
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task WriteToFileAsync_CreatesValidJsonFileAsync()
|
||||
{
|
||||
var summary = new DeterminismSummaryBuilder()
|
||||
.WithSourceRef("test-sha")
|
||||
.AddResult(CreateMatchResult("sbom", "test-artifact"))
|
||||
.Build();
|
||||
|
||||
var filePath = Path.Combine(_testDirectory, "determinism.json");
|
||||
|
||||
await DeterminismSummaryWriter.WriteToFileAsync(summary, filePath);
|
||||
|
||||
File.Exists(filePath).Should().BeTrue();
|
||||
var content = await File.ReadAllTextAsync(filePath);
|
||||
content.Should().Contain("\"schemaVersion\": \"1.0\"");
|
||||
content.Should().Contain("\"sourceRef\": \"test-sha\"");
|
||||
content.Should().Contain("\"status\": \"pass\"");
|
||||
}
|
||||
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task WriteToFileAsync_CreatesDirectoryIfNeededAsync()
|
||||
{
|
||||
var summary = new DeterminismSummaryBuilder().Build();
|
||||
var filePath = Path.Combine(_testDirectory, "nested", "dir", "determinism.json");
|
||||
|
||||
await DeterminismSummaryWriter.WriteToFileAsync(summary, filePath);
|
||||
|
||||
File.Exists(filePath).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ToJson_ReturnsValidJson()
|
||||
{
|
||||
var summary = new DeterminismSummaryBuilder()
|
||||
.AddResult(CreateMatchResult("sbom", "artifact"))
|
||||
.AddResult(CreateDriftResult("vex", "document"))
|
||||
.Build();
|
||||
|
||||
var json = DeterminismSummaryWriter.ToJson(summary);
|
||||
|
||||
json.Should().Contain("\"schemaVersion\": \"1.0\"");
|
||||
json.Should().Contain("\"status\": \"fail\"");
|
||||
json.Should().Contain("\"total\": 2");
|
||||
json.Should().Contain("\"matched\": 1");
|
||||
json.Should().Contain("\"drifted\": 1");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user