Repository navigation
test(azure): make cache, compute and managedredis unit tests hermetic - #266
Conversation
…ainst live calls Tests that built a client without a SKU pager made live management.azure.com calls (20, 16 and 12 CONNECT attempts, 28-48s per package without network). Inject the existing mock pagers and add the zero-external-requests TestMain guard from the database package; the run fails if any test reaches the proxy.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour. 📝 WalkthroughWalkthroughTests in the Azure cache, compute, and managedredis packages now stub pagers before SKU and recommendation checks. Each package also adds a proxy-based guard that counts outbound requests and fails successful test runs if requests reach the proxy. ChangesAzure test network guards
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Other · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to The changed tests retain API-error fallback coverage, and no concrete issue requiring a fix before merge was established. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Closes #258
Measured with a counting loopback proxy (HTTPS_PROXY set, NO_PROXY empty, go test -short):
Tests that made the calls and the live client they left un-stubbed:
Fix is test-only: set the existing mock pagers. Each package gets a network_guard_test.go like database's (#257): TestMain points HTTPS_PROXY/HTTP_PROXY at a counting 403 proxy, a counting test pins the previously live path, and TestMain also fails the run if any test reached the proxy. Removing one stub per package makes the run fail with 4 requests reported.
Gates (providers/azure, GOWORK=off): go build, go vet, go test -race -short -mod=readonly ./..., go mod tidy -diff, gocyclo -over 10, misspell -locale US all exit 0.
Summary by CodeRabbit