Some checks failed
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Policy Simulation / policy-simulate (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
57 lines
2.3 KiB
C#
57 lines
2.3 KiB
C#
using System.Text.Json;
|
|
using FluentAssertions;
|
|
using Xunit;
|
|
|
|
namespace StellaOps.Reachability.FixtureTests;
|
|
|
|
public sealed class FixtureCoverageTests
|
|
{
|
|
private static readonly string RepoRoot = ReachbenchFixtureTests.LocateRepoRoot();
|
|
private static readonly string ReachabilityRoot = Path.Combine(RepoRoot, "tests", "reachability");
|
|
private static readonly string CorpusRoot = Path.Combine(ReachabilityRoot, "corpus");
|
|
private static readonly string SamplesPublicRoot = Path.Combine(ReachabilityRoot, "samples-public");
|
|
|
|
[Fact]
|
|
public void CorpusAndPublicSamplesCoverExpectedLanguageBuckets()
|
|
{
|
|
var corpusLanguages = ReadManifestLanguages(Path.Combine(CorpusRoot, "manifest.json"));
|
|
corpusLanguages.Should().Contain(new[] { "dotnet", "go", "python", "rust" });
|
|
|
|
var samplesLanguages = ReadManifestLanguages(Path.Combine(SamplesPublicRoot, "manifest.json"));
|
|
samplesLanguages.Should().Contain(new[] { "csharp", "js", "php" });
|
|
}
|
|
|
|
[Fact]
|
|
public void CorpusManifestIsSorted()
|
|
{
|
|
var keys = ReadManifestKeys(Path.Combine(CorpusRoot, "manifest.json"));
|
|
keys.Should().NotBeEmpty("corpus manifest should have entries");
|
|
keys.Should().BeInAscendingOrder(StringComparer.Ordinal);
|
|
}
|
|
|
|
private static string[] ReadManifestLanguages(string manifestPath)
|
|
{
|
|
File.Exists(manifestPath).Should().BeTrue($"{manifestPath} should exist");
|
|
|
|
using var doc = JsonDocument.Parse(File.ReadAllBytes(manifestPath));
|
|
return doc.RootElement.EnumerateArray()
|
|
.Select(entry => entry.GetProperty("language").GetString())
|
|
.Where(language => !string.IsNullOrWhiteSpace(language))
|
|
.Select(language => language!)
|
|
.Distinct(StringComparer.Ordinal)
|
|
.OrderBy(language => language, StringComparer.Ordinal)
|
|
.ToArray();
|
|
}
|
|
|
|
private static string[] ReadManifestKeys(string manifestPath)
|
|
{
|
|
File.Exists(manifestPath).Should().BeTrue($"{manifestPath} should exist");
|
|
|
|
using var doc = JsonDocument.Parse(File.ReadAllBytes(manifestPath));
|
|
return doc.RootElement.EnumerateArray()
|
|
.Select(entry => $"{entry.GetProperty("language").GetString()}/{entry.GetProperty("id").GetString()}")
|
|
.ToArray();
|
|
}
|
|
}
|
|
|