Files
git.stella-ops.org/src/Notifier/StellaOps.Notifier/StellaOps.Notifier.Tests/PackApprovalTemplateSeederTests.cs
StellaOps Bot 49922dff5a
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Notify Smoke Test / Notifier Service Tests (push) Has been cancelled
Notify Smoke Test / Notification Smoke Test (push) Has been cancelled
Notify Smoke Test / Notify Unit Tests (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Manifest Integrity / Validate Schema Integrity (push) Has been cancelled
Manifest Integrity / Validate Contract Documents (push) Has been cancelled
Manifest Integrity / Validate Pack Fixtures (push) Has been cancelled
Manifest Integrity / Audit SHA256SUMS Files (push) Has been cancelled
Manifest Integrity / Verify Merkle Roots (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Risk Bundle CI / risk-bundle-build (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Risk Bundle CI / risk-bundle-offline-kit (push) Has been cancelled
Risk Bundle CI / publish-checksums (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
devportal-offline / build-offline (push) Has been cancelled
Mirror Thin Bundle Sign & Verify / mirror-sign (push) Has been cancelled
up the blokcing tasks
2025-12-11 02:32:18 +02:00

63 lines
2.4 KiB
C#

using Microsoft.Extensions.Logging.Abstractions;
using StellaOps.Notifier.Tests.Support;
using StellaOps.Notifier.WebService.Setup;
using Xunit;
namespace StellaOps.Notifier.Tests;
public sealed class PackApprovalTemplateSeederTests
{
[Fact]
public async Task SeedAsync_loads_templates_from_docs()
{
var templateRepo = new InMemoryTemplateRepository();
var channelRepo = new InMemoryChannelRepository();
var ruleRepo = new InMemoryRuleRepository();
var logger = NullLogger<PackApprovalTemplateSeeder>.Instance;
var contentRoot = LocateRepoRoot();
var count = await PackApprovalTemplateSeeder.SeedTemplatesAsync(
templateRepo,
contentRoot,
logger,
cancellationToken: TestContext.Current.CancellationToken);
var routed = await PackApprovalTemplateSeeder.SeedRoutingAsync(
channelRepo,
ruleRepo,
logger,
cancellationToken: TestContext.Current.CancellationToken);
Assert.True(count >= 2, "Expected at least two templates to be seeded.");
Assert.Equal(3, routed);
var templates = await templateRepo.ListAsync("tenant-sample", TestContext.Current.CancellationToken);
Assert.Contains(templates, t => t.TemplateId == "tmpl-pack-approval-slack-en");
Assert.Contains(templates, t => t.TemplateId == "tmpl-pack-approval-email-en");
var channels = await channelRepo.ListAsync("tenant-sample", cancellationToken: TestContext.Current.CancellationToken);
Assert.Contains(channels, c => c.ChannelId == "chn-pack-approvals-slack");
Assert.Contains(channels, c => c.ChannelId == "chn-pack-approvals-email");
var rules = await ruleRepo.ListAsync("tenant-sample", TestContext.Current.CancellationToken);
Assert.Contains(rules, r => r.RuleId == "rule-pack-approvals-default");
}
private static string LocateRepoRoot()
{
var directory = AppContext.BaseDirectory;
while (directory != null)
{
if (File.Exists(Path.Combine(directory, "StellaOps.sln")) ||
File.Exists(Path.Combine(directory, "StellaOps.Notifier.sln")))
{
return directory;
}
directory = Directory.GetParent(directory)?.FullName;
}
throw new InvalidOperationException("Unable to locate repository root.");
}
}