test(generators): cover bulkhead and rate limiting#444
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR expands generator test coverage and hardens the Bulkhead and Rate Limit policy source generators, primarily around nested host type shapes and additional diagnostics/default behaviors (in support of #413’s generator coverage goals).
Changes:
- Convert Bulkhead/Rate Limit generator tests to TinyBDD xUnit scenario chains and add coverage for more host shapes (nested/accessibility variants), defaults, and malformed inputs.
- Update BulkheadPolicyGenerator and RateLimitPolicyGenerator emission to wrap generated members inside containing types (nested type support).
- Expand diagnostic coverage for invalid configurations and non-partial hosts.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| test/PatternKit.Generators.Tests/RateLimitPolicyGeneratorTests.cs | Converts to TinyBDD.Xunit base + adds scenarios for defaults, nested hosts, invalid configs, and malformed result type. |
| test/PatternKit.Generators.Tests/BulkheadPolicyGeneratorTests.cs | Same test structure conversion and coverage expansion for bulkhead generation branches. |
| src/PatternKit.Generators/RateLimiting/RateLimitPolicyGenerator.cs | Adds nested containing-type wrapper emission for generated factory method. |
| src/PatternKit.Generators/Bulkhead/BulkheadPolicyGenerator.cs | Adds nested containing-type wrapper emission for generated factory method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private static void AppendTypeDeclaration(StringBuilder sb, INamedTypeSymbol type, int indentLevel) | ||
| { | ||
| sb.Append(new string(' ', indentLevel * 4)); | ||
| sb.Append(GetAccessibility(type.DeclaredAccessibility)).Append(' '); | ||
| if (type.IsStatic) |
| var containingTypes = GetContainingTypes(type); | ||
| var indentLevel = 0; | ||
| foreach (var containingType in containingTypes) | ||
| { | ||
| AppendTypeDeclaration(sb, containingType, indentLevel); |
| private static void AppendTypeDeclaration(StringBuilder sb, INamedTypeSymbol type, int indentLevel) | ||
| { | ||
| sb.Append(new string(' ', indentLevel * 4)); | ||
| sb.Append(GetAccessibility(type.DeclaredAccessibility)).Append(' '); | ||
| if (type.IsStatic) |
| var containingTypes = GetContainingTypes(type); | ||
| var indentLevel = 0; | ||
| foreach (var containingType in containingTypes) | ||
| { | ||
| AppendTypeDeclaration(sb, containingType, indentLevel); |
Test Results 12 files 12 suites 10m 46s ⏱️ Results for commit 459012f. |
Code Coverage |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #444 +/- ##
==========================================
+ Coverage 91.49% 96.74% +5.24%
==========================================
Files 551 551
Lines 44900 44940 +40
Branches 6470 6476 +6
==========================================
+ Hits 41082 43477 +2395
+ Misses 1549 1463 -86
+ Partials 2269 0 -2269
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Validation
Refs #413