test(providers/azure): make IsConfigured guards deterministic - #1468
Conversation
…1465) The three affected tests wrapped assertions in `if !p.IsConfigured()` around a bare `&AzureProvider{}`. With no credProvider injected, IsConfigured() fell through to the real DefaultAzureCredential lookup, which succeeds on virtually any machine, so the guarded negative-path assertions silently never ran. Inject the existing mockCredentialProvider configured to fail so IsConfigured() deterministically returns false, and assert unconditionally instead of behind an if-guard.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThree AzureProvider tests now inject failing credential-provider mocks, explicitly assert the provider is unconfigured, and unconditionally verify the expected errors from credential and client retrieval methods. ChangesAzure provider test determinism
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Closes #1465
Summary
providers/azure/provider_test.gohad three tests (TestAzureProvider_GetCredentials_NotConfigured,TestAzureProvider_GetServiceClient_NotConfigured,TestAzureProvider_GetRecommendationsClient_NotConfigured) that wrapped their assertions inif !p.IsConfigured() { ... }on a bare&AzureProvider{}.credProviderinjected,IsConfigured()fell through to the realrealCredentialProvider{}.NewDefaultAzureCredential(). Construction succeeds on virtually any machine, so the guarded "not configured" assertions silently never ran, and the pattern normalized real-credential construction in tests.mockCredentialProviderconfigured to fail (SetCredentialProvider), assertsIsConfigured()is false unconditionally, and runs the negative-path assertion unconditionally instead of behind anif.IsConfigured()guards or hazardous bare&AzureProvider{}constructions; no other instances found. The remaining bare&AzureProvider{}uses either don't touchIsConfigured()/credentials (Name(),DisplayName(),GetDefaultRegion(),GetSupportedServices()) or already inject a mock credential provider immediately after construction.Test plan
gofmt -l .clean (fromproviders/azure/)go vet ./...clean (fromproviders/azure/)go test ./... -count=1green, 710 tests passed across 14 packages (fromproviders/azure/)🤖 Generated with Claude Code
Summary by CodeRabbit