up
Some checks failed
Docs CI / lint-and-preview (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
Symbols Server CI / symbols-smoke (push) Has been cancelled
devportal-offline / build-offline (push) Has been cancelled

This commit is contained in:
StellaOps Bot
2025-11-24 20:57:49 +02:00
parent 46c8c47d06
commit 7c39058386
92 changed files with 3549 additions and 157 deletions

View File

@@ -0,0 +1,54 @@
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.SeedAsync(templateRepo, contentRoot, logger, TestContext.Current.CancellationToken);
var routed = await PackApprovalTemplateSeeder.SeedRoutingAsync(channelRepo, ruleRepo, logger, 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", 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.");
}
}