Skip ResourceHealth tests that depend on Azure CLI profile absence#2560
Conversation
7710ba1 to
a328258
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates Azure ResourceHealth unit tests to avoid failing in environments where an Azure CLI default subscription (or other default subscription source) is available, by conditionally skipping validation cases that expect missing --subscription to fail.
Changes:
- Added conditional
Assert.SkipWhen(...)logic to subscription-missing validation scenarios. - Introduced
CommandHelper.GetDefaultSubscription()checks in ResourceHealth unit tests to detect presence of a default subscription.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.ResourceHealth/tests/Azure.Mcp.Tools.ResourceHealth.UnitTests/ServiceHealthEvents/ServiceHealthEventsListCommandTests.cs | Skips the “missing subscription” validation when a default subscription is available. |
| tools/Azure.Mcp.Tools.ResourceHealth/tests/Azure.Mcp.Tools.ResourceHealth.UnitTests/AvailabilityStatus/AvailabilityStatusGetCommandTests.cs | Skips the “missing subscription” validation when a default subscription is available; adds related usings. |
Comments suppressed due to low confidence (1)
tools/Azure.Mcp.Tools.ResourceHealth/tests/Azure.Mcp.Tools.ResourceHealth.UnitTests/AvailabilityStatus/AvailabilityStatusGetCommandTests.cs:11
using Microsoft.Mcp.Tests.Helpers;is not used anywhere in this test file. With warnings treated as errors in this repo, this will fail the build—please remove the unused using (or use the type you intended to reference).
using Microsoft.Mcp.Core.Helpers;
using Microsoft.Mcp.Core.Options;
using Microsoft.Mcp.Tests.Client;
using NSubstitute;
using NSubstitute.ExceptionExtensions;
jongio
left a comment
There was a problem hiding this comment.
Straightforward fix. The Assert.SkipWhen usage aligns with existing test patterns in the repo. The skip condition correctly fires only when CommandHelper.GetDefaultSubscription() returns a value, meaning the missing-subscription validation path is unreachable.
In ServiceHealthEventsListCommandTests, the !shouldSucceed && string.IsNullOrWhiteSpace(args) guard correctly targets only the empty-args case - the ("--subscription sub123", false) path tests missing --filter, not missing subscription, so it isn't affected.
No issues found. CI is still running.
There was a problem hiding this comment.
Not the biggest fan of this change as it's just hiding a larger problem where we can't inject and substitute environment subscription retrieval in tests.
If we are going to make a change to skip these in this circumstance for now, can we make this a shared method in Microsot.Mcp.Tests so that when we do fix the larger problem we can delete / update the handling in one central spot.
a328258 to
4d3dd0c
Compare
jongio
left a comment
There was a problem hiding this comment.
Rebased cleanly. The refactoring to TestEnvironment.SkipIfDefaultSubscriptionConfigured() is a good improvement over inline Assert.SkipWhen - centralizes the logic and provides a clear skip message. No issues.
…icrosoft#2560) * Skip ResourceHealth tests that depend on Azure CLI profile absence when the profile is present * Move SkipIfDefaultSubscriptionConfigured to shared location TestEnvironment
What does this PR do?
Skip ResourceHealth tests that depend on Azure CLI profile absence when the profile is present
Pre-merge Checklist
servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationREADME.mdchanges running the script./eng/scripts/Process-PackageReadMe.ps1. See Package READMEToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.jsonbreaking-changelabelservers/Azure.Mcp.Server/docs/azmcp-commands.md./eng/scripts/Update-AzCommandsMetadata.ps1to update tool metadata inazmcp-commands.md(required for CI)servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline