| 1 | using AgentForge.Plugin.RepositoryImport.GitHub.Core; |
| 2 | |
| 3 | namespace AgentForge.Tests; |
| 4 | |
| 5 | public sealed class ForgeImportCatalogMatcherTests |
| 6 | { |
| 7 | private static readonly string CatalogPath = Path.GetFullPath(Path.Combine( |
| 8 | AppContext.BaseDirectory, |
| 9 | "..", "..", "..", "..", "..", |
| 10 | "config", |
| 11 | "import-catalog.ai-guiders.toml")); |
| 12 | |
| 13 | [Fact] |
| 14 | public void Loads_catalog_and_maps_agent_forge_to_showcase_platform() |
| 15 | { |
| 16 | var loader = new ForgeImportCatalogLoader(); |
| 17 | var doc = loader.Load(CatalogPath); |
| 18 | Assert.Equal("ai-guiders", doc.Catalog.ForgeOrg); |
| 19 | Assert.True(doc.Explicit.Count > 0); |
| 20 | Assert.True(doc.Rules.Count > 0); |
| 21 | |
| 22 | var matcher = new ForgeImportCatalogMatcher(); |
| 23 | var match = matcher.Match( |
| 24 | doc, |
| 25 | new GitHubRepositoryInfo("agent-forge", "https://github.com/AI-Guiders/agent-forge.git", false, false, [])); |
| 26 | |
| 27 | Assert.Equal("showcase/platform/forge", match.CatalogPath); |
| 28 | Assert.Equal("agent-forge", match.ForgeSlug); |
| 29 | } |
| 30 | |
| 31 | [Fact] |
| 32 | public void Maps_roslyn_mcp_to_static_analyzers_branch() |
| 33 | { |
| 34 | var loader = new ForgeImportCatalogLoader(); |
| 35 | var doc = loader.Load(CatalogPath); |
| 36 | var matcher = new ForgeImportCatalogMatcher(); |
| 37 | var match = matcher.Match( |
| 38 | doc, |
| 39 | new GitHubRepositoryInfo("RoslynMcp", "https://github.com/AI-Guiders/RoslynMcp.git", false, false, [])); |
| 40 | |
| 41 | Assert.Equal("showcase/mcp-tools/dotnet/static-analyzers/roslyn", match.CatalogPath); |
| 42 | Assert.Equal("roslyn-mcp", match.ForgeSlug); |
| 43 | } |
| 44 | |
| 45 | [Fact] |
| 46 | public void Maps_forge_zoo_prefix_to_backup_forge_zoo() |
| 47 | { |
| 48 | var loader = new ForgeImportCatalogLoader(); |
| 49 | var doc = loader.Load(CatalogPath); |
| 50 | var matcher = new ForgeImportCatalogMatcher(); |
| 51 | var match = matcher.Match( |
| 52 | doc, |
| 53 | new GitHubRepositoryInfo("forge-zoo-cad", "https://github.com/AI-Guiders/forge-zoo-cad.git", true, false, [])); |
| 54 | |
| 55 | Assert.Equal("backup/forge-zoo/cad", match.CatalogPath); |
| 56 | Assert.Equal("forge-zoo-cad", match.ForgeSlug); |
| 57 | } |
| 58 | |
| 59 | [Fact] |
| 60 | public void Skips_dot_github_meta_repo() |
| 61 | { |
| 62 | var loader = new ForgeImportCatalogLoader(); |
| 63 | var doc = loader.Load(CatalogPath); |
| 64 | var matcher = new ForgeImportCatalogMatcher(); |
| 65 | var match = matcher.Match( |
| 66 | doc, |
| 67 | new GitHubRepositoryInfo(".github", "https://github.com/AI-Guiders/.github.git", false, false, [])); |
| 68 | |
| 69 | Assert.True(match.Skip); |
| 70 | } |
| 71 | } |
| 72 | |