Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughCapacity calculation now accepts an explicit Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/scheduling/reservations/commitments/api_report_capacity_test.go (1)
201-241: Optional: extract repeatedPerAZassertions into a local helper.The RAM/Cores/Instances checks repeat the same structure; a small helper in this file would keep the test shorter and easier to maintain.
♻️ Example refactor
+assertResourceAZs := func(t *testing.T, report liquid.ServiceCapacityReport, rn liquid.ResourceName, azs []liquid.AvailabilityZone, label string) { + t.Helper() + res := report.Resources[rn] + if res == nil { + t.Fatalf("Expected %s resource to exist", label) + } + if len(res.PerAZ) != len(azs) { + t.Errorf("Expected %d AZs for %s resource, got %d", len(azs), label, len(res.PerAZ)) + } + for _, az := range azs { + if _, ok := res.PerAZ[az]; !ok { + t.Errorf("Expected %s resource to have entry for AZ %s", label, az) + } + } +} @@ - // Check RAM resource has entries for all requested AZs - ramResource := report.Resources[liquid.ResourceName("hw_version_test-group_ram")] - ... - // Check Cores resource has entries for all requested AZs - coresResource := report.Resources[liquid.ResourceName("hw_version_test-group_cores")] - ... - // Check Instances resource has entries for all requested AZs - instancesResource := report.Resources[liquid.ResourceName("hw_version_test-group_instances")] - ... + assertResourceAZs(t, report, liquid.ResourceName("hw_version_test-group_ram"), req.AllAZs, "RAM") + assertResourceAZs(t, report, liquid.ResourceName("hw_version_test-group_cores"), req.AllAZs, "Cores") + assertResourceAZs(t, report, liquid.ResourceName("hw_version_test-group_instances"), req.AllAZs, "Instances")As per coding guidelines, "Test files should be short and contain only the necessary test cases" and "Avoid creating testing libraries; keep helper functions in the same file as the tests that use them."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/scheduling/reservations/commitments/api_report_capacity_test.go` around lines 201 - 241, Extract the repeated PerAZ checks into a small helper in this test file (e.g., assertPerAZEntries(report.Resources, resourceName liquid.ResourceName, req.AllAZs)) that accepts the resources map and a resource name, verifies the resource exists, checks len(resource.PerAZ) equals len(req.AllAZs) and that each az from req.AllAZs is present; then replace the three repeated blocks that reference ramResource, coresResource, and instancesResource with three calls to this helper using "hw_version_test-group_ram", "hw_version_test-group_cores", and "hw_version_test-group_instances".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/scheduling/reservations/commitments/api_report_capacity_test.go`:
- Around line 201-241: Extract the repeated PerAZ checks into a small helper in
this test file (e.g., assertPerAZEntries(report.Resources, resourceName
liquid.ResourceName, req.AllAZs)) that accepts the resources map and a resource
name, verifies the resource exists, checks len(resource.PerAZ) equals
len(req.AllAZs) and that each az from req.AllAZs is present; then replace the
three repeated blocks that reference ramResource, coresResource, and
instancesResource with three calls to this helper using
"hw_version_test-group_ram", "hw_version_test-group_cores", and
"hw_version_test-group_instances".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 67c423bb-a2c2-4cd5-bfbd-a822ba827bbd
📒 Files selected for processing (3)
internal/scheduling/reservations/commitments/api_report_capacity.gointernal/scheduling/reservations/commitments/api_report_capacity_test.gointernal/scheduling/reservations/commitments/capacity.go
Test Coverage ReportTest Coverage 📊: 68.1% |
No description provided.