Repository navigation
{Tests} Add validation error unit tests for Resources - #1469
Open
MaddyMicrosoft wants to merge 6 commits into
Open
MaddyMicrosoft wants to merge 6 commits into
MaddyMicrosoft wants to merge 6 commits into
Conversation
Add a dedicated unit test project for the Resources extension, with a helper that initializes processors against a pipeline that throws on any request. Register it in azclips.slnx so CI runs it, point the Resources InternalsVisibleTo at it, and list it in the testing wiki. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover every input case of RoleAssignmentScope, DeploymentRequestBuilder, ResourceGroupIdResolver, DeploymentIdResolver and JmesPathCondition with exact messages: each rejection reason, blank and null values, both sides of each boundary, and accepted inputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add single-assert tests for the management group, tenant wait and deployment operation orchestrators, and tighten the resource group deployment create, validate and what-if tests: one test per shared validator call plus each orchestrator's own rules (rollback options, ResultFormat, required inputs, wait conditions). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assert exact messages for role assignment create, list and delete input rules (assignee, role, scope and resource group, --all combinations, GUID checks, blank values). The shared AssertThrows helpers now require the exact exception type and message while keeping their existing checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assert exact messages for az rest input rules (method, URL vs piece-wise parameters, ARM host and https, URI parameters, headers) and resource group set/update rules (name vs id, tags, --set paths). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…class under test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the Resources input-validation test changes.
No open issues 🎉
What changed in this PR
Adds regression tests for Resources input validation, covering exception types, user-facing messages, and validation before HTTP requests without changing product behavior.
Changes:
- Adds a Resources unit-test project covering shared validators and deployment orchestrators.
- Adds validation cases and strengthens message assertions in existing CLI test suites.
- Registers the project, grants internal access for testing, and updates the testing wiki.
| File | Description |
|---|---|
wiki/02-deep-dive/testing-benchmarking.md |
Lists the new Resources test project. |
tests/Extensions.Resources.Tests/WhatIfManagementGroupDeploymentProcessor_OrchestratorTests.cs |
Tests management-group what-if validation and error precedence. |
tests/Extensions.Resources.Tests/WaitTenantDeploymentProcessor_OrchestratorTests.cs |
Tests missing wait conditions and invalid custom expressions. |
tests/Extensions.Resources.Tests/ValidateManagementGroupDeploymentProcessor_OrchestratorTests.cs |
Tests management-group validation before requests. |
tests/Extensions.Resources.Tests/RoleAssignmentScopeTests.cs |
Tests scope validation and normalization. |
tests/Extensions.Resources.Tests/ResourcesProcessorTestHelpers.cs |
Provides shared processor initialization for mocked tests. |
tests/Extensions.Resources.Tests/ResourceGroupIdResolverTests.cs |
Tests resource-group ID parsing and errors. |
tests/Extensions.Resources.Tests/ManagementGroupDeploymentOrchestratorBaseTests.cs |
Tests shared management-group deployment checks. |
tests/Extensions.Resources.Tests/JmesPathConditionTests.cs |
Tests expression validation and error prefixes. |
tests/Extensions.Resources.Tests/GetResourceGroupDeploymentOperationProcessor_OrchestratorTests.cs |
Tests rejection of empty operation IDs. |
tests/Extensions.Resources.Tests/Extensions.Resources.Tests.csproj |
Defines test dependencies, references, and Release signing. |
tests/Extensions.Resources.Tests/DeploymentRequestBuilderTests.cs |
Tests deployment inputs, parameter files, and required parameters. |
tests/Extensions.Resources.Tests/DeploymentIdResolverTests.cs |
Tests deployment ID parsing at resource-group and management-group scopes. |
tests/Extensions.Resources.Tests/CreateManagementGroupDeploymentProcessor_OrchestratorTests.cs |
Tests management-group creation validation before requests. |
tests/Cli.Tests/RoleAssignmentDeleteTests.cs |
Pins delete validation messages and adds blank-name cases. |
tests/Cli.Tests/RoleAssignmentCreateTests.cs |
Pins create validation messages and adds invalid principal and role cases. |
tests/Cli.Tests/RoleAssignmentCliTests.cs |
Adds role-assignment list validation cases. |
tests/Cli.Tests/RestProcessorTests.cs |
Expands REST validation coverage and exact-message assertions. |
tests/Cli.Tests/ResourcesProcessorMockHelpers.cs |
Adds shared mock initialization with optional profiles. |
tests/Cli.Tests/ResourceGroupDeploymentWhatIfTests.cs |
Tests invalid result format, resource group, and mode. |
tests/Cli.Tests/ResourceGroupDeploymentValidateTests.cs |
Tests rollback conflicts and strengthens deployment validation assertions. |
tests/Cli.Tests/ResourceGroupDeploymentCreateTests.cs |
Tests rollback conflicts, missing resource groups, and invalid modes. |
tests/Cli.Tests/GroupUpdateTests.cs |
Expands address, tag, and update-expression validation tests. |
src/Extensions/Resources/Extensions.Resources.csproj |
Grants the new test assembly access to internal validators. |
azclips.slnx |
Registers the Resources test project. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related command
az deployment group create|validate|what-if,az deployment mg create|validate|what-if,az deployment tenant wait,az deployment operation group show,az role assignment create|delete|list,az group update,az rest(and the matching PowerShell cmdlets)Description
Adds unit tests that lock in the exact user-facing error messages produced by custom input validation in the Resources extension. If the core argument parser, the engine, or an orchestrator changes in a way that alters or skips one of these errors (for example during the upcoming parameter-set work), a test will now fail.
New test project:
tests/Extensions.Resources.Tests(registered inazclips.slnxand listed in the testing wiki), matching the other extension test projects.InternalsVisibleToforExtensions.Resources.TestsinExtensions.Resources.csprojso the internal validators can be tested directly. No product behaviour change.What is covered:
DeploymentRequestBuilder,DeploymentIdResolver,ResourceGroupIdResolver,RoleAssignmentScope,JmesPathConditionandManagementGroupDeploymentOrchestratorBase. Each covers every rejection reason, including blank and null values.ResultFormat).Cli.Tests(resource group deployment create/validate/what-if, role assignment create/delete/list, group update and rest). Only the tests added by this PR follow the new style; existing tests in those files are unchanged.How the tests work:
Current behaviour:comment. For example, deployment validate throwsArgumentExceptionwhere create throwsInvalidInputExceptionfor the same rollback rule, and malformed deployment ids surface asInvalidOperationException. These are left for separate fixes.[Component Name]for customer-facing changes or{Component Name}for non-customer-facing changes, and does not end with trailing punctuation or spaces.