consolidate the tests locations
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user