Az.FileShares - Add Tests for fileshares#29256
Open
ankushbindlish2 wants to merge 8 commits intoAzure:mainfrom
Open
Az.FileShares - Add Tests for fileshares#29256ankushbindlish2 wants to merge 8 commits intoAzure:mainfrom
ankushbindlish2 wants to merge 8 commits intoAzure:mainfrom
Conversation
Add prerequisites documentation and installer script for TypeSpec-based FileShare development (PREREQUISITES-STATUS.md, check-and-install-prerequisites.ps1) and add eng package manifest to pull TypeSpec packages. Include generated Pester module files and related test assets for FileShare, plus test environment templates, test helpers, sample implementation, and a test plan/status. Update FileShare project metadata and docs (AssemblyInfo, Az.FileShare.psd1, Az.FileShare.md) and adjust several FileShare test scripts. Also remove obsolete EventGrid generate-info.json.
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
Contributor
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds/activates FileShare Autorest Pester tests and introduces JSON-based test environment assets to support TypeSpec-based FileShare development and validation.
Changes:
- Load test environment variables from JSON and optionally create the test resource group in
setupEnv. - Un-skip multiple FileShare cmdlet Pester tests and implement live assertions.
- Add JSON request/asset files for tests and include local/env templates.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| src/FileShare/FileShare.Autorest/test/utils.ps1 | Loads env values from JSON and creates RG if needed; writes env back to disk |
| src/FileShare/FileShare.Autorest/test/test-snapshot-update.json | Adds snapshot update request payload asset |
| src/FileShare/FileShare.Autorest/test/test-recommendation.json | Adds provisioning recommendation request payload asset |
| src/FileShare/FileShare.Autorest/test/test-availability.json | Adds name availability request payload asset |
| src/FileShare/FileShare.Autorest/test/localEnv.json | Adds local live-test environment values |
| src/FileShare/FileShare.Autorest/test/env.json.template | Adds template env file for non-local scenarios |
| src/FileShare/FileShare.Autorest/test/env.json | Adds env file used by tests when not in live mode |
| src/FileShare/FileShare.Autorest/test/Update-AzFileShareSnapshot.Tests.ps1 | Implements Update snapshot tests (expanded/json/identity variants) |
| src/FileShare/FileShare.Autorest/test/Update-AzFileShare.Tests.ps1 | Implements Update file share tests (expanded/json/identity variants) |
| src/FileShare/FileShare.Autorest/test/Test-AzFileShareNameAvailability.Tests.ps1 | Implements name availability tests (expanded/json/body/identity variants) |
| src/FileShare/FileShare.Autorest/test/Remove-AzFileShareSnapshot.Tests.ps1 | Implements snapshot delete tests (expanded/identity variants) |
| src/FileShare/FileShare.Autorest/test/Remove-AzFileShare.Tests.ps1 | Implements file share delete tests |
| src/FileShare/FileShare.Autorest/test/New-AzFileShareSnapshot.Tests.ps1 | Implements snapshot create tests (expanded/json/identity variants) |
| src/FileShare/FileShare.Autorest/test/New-AzFileShare.Tests.ps1 | Implements file share create tests (expanded/json variants) |
| src/FileShare/FileShare.Autorest/test/Get-AzFileShareUsageData.Tests.ps1 | Implements usage data tests |
| src/FileShare/FileShare.Autorest/test/Get-AzFileShareSnapshot.Tests.ps1 | Implements snapshot get/list tests |
| src/FileShare/FileShare.Autorest/test/Get-AzFileShareProvisioningRecommendation.Tests.ps1 | Implements provisioning recommendation tests (expanded/json/body/identity variants) |
| src/FileShare/FileShare.Autorest/test/Get-AzFileShareLimit.Tests.ps1 | Implements limit tests (expanded/identity variants) |
| src/FileShare/FileShare.Autorest/test/Get-AzFileShare.Tests.ps1 | Implements file share get/list tests |
src/FileShare/FileShare.Autorest/test/Get-AzFileShareProvisioningRecommendation.Tests.ps1
Show resolved
Hide resolved
src/FileShare/FileShare.Autorest/test/Get-AzFileShareProvisioningRecommendation.Tests.ps1
Show resolved
Hide resolved
src/FileShare/FileShare.Autorest/test/Update-AzFileShareSnapshot.Tests.ps1
Outdated
Show resolved
Hide resolved
blueww
reviewed
Mar 10, 2026
blueww
reviewed
Mar 10, 2026
- Add CRUD operation tests - Add edge case scenarios tests - Add negative/error handling tests - Add pipeline functionality tests - Add private endpoint tests - Add resource move tests - Add complex scenario tests - Add test utilities
Contributor
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
- Add scenario tests: CRUD, ComplexScenarios, EdgeCases, Negative, NegativeTests, Pipeline, PrivateEndpoint - Add recordings for all test scenarios (16 recording files) - Update individual cmdlet tests with fixes - Update env.json and localEnv.json with test configuration - Remove obsolete test files (FileShare-ResourceMove, test-*.json) - Rename PipelineTests and PrivateEndpointTests to standard naming Test results: 159 passed, 0 failed, 31 skipped
Contributor
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
Prevents temporary JSON files created during test execution from being committed: - test-*.json (test-availability.json, test-recommendation.json, test-snapshot.json, etc.) - *-Params.json (test output files) - run-tests.ps1 (local helper script, not part of standard test framework)
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 43 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (7)
src/FileShare/FileShare.Autorest/test/localEnv.json:1
- This file commits concrete Tenant and Subscription IDs. Even if not secret, these are environment-specific identifiers and typically should not be checked in. Replace them with placeholders (e.g., "00000000-0000-0000-0000-000000000000") and document that users must override via local, untracked settings (or rely on
Get-AzContextinsetupEnv).
src/FileShare/FileShare.Autorest/test/localEnv.json:1 - This file commits concrete Tenant and Subscription IDs. Even if not secret, these are environment-specific identifiers and typically should not be checked in. Replace them with placeholders (e.g., "00000000-0000-0000-0000-000000000000") and document that users must override via local, untracked settings (or rely on
Get-AzContextinsetupEnv).
src/FileShare/FileShare.Autorest/test/utils.ps1:1 - This introduces real ARM calls during environment setup for any mode. In playback (and often record), the harness typically must avoid unrecorded ARM calls like
Get-AzResourceGroup/New-AzResourceGroup, otherwise tests can fail or unexpectedly mutate a subscription. Gate this block so it runs only when appropriate (commonly$TestMode -ne 'playback', or even only inlive/record), and keep playback strictly off-network.
src/FileShare/FileShare.Autorest/test/utils.ps1:1 Get-Contentwithout-Rawreturns an array of lines.ConvertFrom-Jsoncan fail or behave inconsistently when fed a string array (especially if the JSON becomes multi-line or contains trailing whitespace). UseGet-Content -Rawfor reliable JSON parsing.
src/FileShare/FileShare.Autorest/test/Update-AzFileShareSnapshot.Tests.ps1:1- These tests update
$env.snapshotName01but the test file does not create (or verify existence of) that snapshot first. This makes the test order-dependent and can fail in live runs. Create the snapshot in aBeforeAll/BeforeEachwithin thisDescribe, then update it, and delete it inAfterAllto keep tests isolated.
src/FileShare/FileShare.Autorest/test/Test-AzFileShareNameAvailability.Tests.ps1:1 - These tests assert
NameAvailableis$truefor fixed names (e.g.,testshare-available,testshare-json). In live/record mode this can legitimately become false if the name becomes unavailable, causing flaky CI. Use a randomized name (e.g., include a GUID suffix) for 'available' assertions, and keep recordings stable via the test framework's sanitization/replacement features if needed.
src/FileShare/FileShare.Autorest/test/Test-AzFileShareNameAvailability.Recording.json:1 - The recorded request body looks base64-encoded, but
isContentBase64is set tofalse. If the mocking framework uses this flag to decode/compare bodies, playback matching can break. Ensure recordings either store the plain JSON withisContentBase64: false, or setisContentBase64: truewhen the content is base64-encoded.
src/FileShare/FileShare.Autorest/test/FileShare-PrivateEndpoint.Tests.ps1
Show resolved
Hide resolved
src/FileShare/FileShare.Autorest/test/FileShare-PrivateEndpoint.Recording.json
Outdated
Show resolved
Hide resolved
Contributor
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
FileShare is a standalone service (Microsoft.FileShares) that does not use Storage Accounts. Removed legacy storageAccountName configuration that was not being used in any tests. - Removed from env.json - Removed from localEnv.json - Removed from env.json.template
Changed from: 70a036f6-8e4d-4615-bad6-149c02e7720d Changed to: 72f988bf-86f1-41af-91ab-2d7cd011db47 This is the well-known Microsoft tenant ID used across Azure PowerShell test configurations, ensuring consistency with other modules in the repository.
This reverts commit ff5e04a.
Contributor
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 43 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (8)
src/FileShare/FileShare.Autorest/test/utils.ps1:1
Get-Contentwithout-Rawpipes the JSON file line-by-line intoConvertFrom-Json, which will fail for multi-line JSON (e.g.,{on the first line). UseGet-Content -Raw -Path $envFilePath | ConvertFrom-Json(orGet-Content -Rawassigned to a string) so the entire JSON document is parsed correctly.
src/FileShare/FileShare.Autorest/test/utils.ps1:1- In non-live modes this selects
env.jsonand then overwrites it at the end ofsetupEnv(). Ifenv.jsonis intended to be a checked-in playback asset, writing to it during test runs will dirty the working tree and can destabilize playback consistency. Consider (mandatory) writing only tolocalEnv.json(or a temp file) and treatingenv.jsonas read-only, or gating theSet-Contentwrite so it only happens in live mode.
src/FileShare/FileShare.Autorest/test/utils.ps1:1 - In non-live modes this selects
env.jsonand then overwrites it at the end ofsetupEnv(). Ifenv.jsonis intended to be a checked-in playback asset, writing to it during test runs will dirty the working tree and can destabilize playback consistency. Consider (mandatory) writing only tolocalEnv.json(or a temp file) and treatingenv.jsonas read-only, or gating theSet-Contentwrite so it only happens in live mode.
src/FileShare/FileShare.Autorest/test/localEnv.json:1 - This file appears to include real SubscriptionId/Tenant GUIDs. Even if these are non-secret, committing real tenant/subscription identifiers is generally treated as sensitive (and also makes the repo less portable). Replace these with placeholders (e.g.,
00000000-0000-0000-0000-000000000000) and document how contributors should populate local values (and ensure the real local file is ignored).
src/FileShare/FileShare.Autorest/test/localEnv.json:1 - This file appears to include real SubscriptionId/Tenant GUIDs. Even if these are non-secret, committing real tenant/subscription identifiers is generally treated as sensitive (and also makes the repo less portable). Replace these with placeholders (e.g.,
00000000-0000-0000-0000-000000000000) and document how contributors should populate local values (and ensure the real local file is ignored).
src/FileShare/FileShare.Autorest/test/env.json:1 env.jsonis checked in and includes subscription/tenant identifiers. If this file is used as a playback/record baseline, it should be sanitized to non-identifying placeholder values (or removed and generated) to avoid leaking tenant metadata and to keep recordings portable across environments.
src/FileShare/FileShare.Autorest/test/env.json.template:1- The template should not embed real subscription/tenant IDs. Use clear placeholder values and add brief guidance for users to fill these in locally. This also avoids copy/paste of real IDs into repos downstream.
src/FileShare/FileShare.Autorest/test/Get-AzFileShare.Recording.json:1 - The recording content includes
systemData.createdBywith what appears to be a real email address (PII). Recordings should be sanitized (e.g., replace with[Filtered]/00000000-.../user@contoso.com) via the test framework's sanitizers before committing.
{
src/FileShare/FileShare.Autorest/test/Get-AzFileShareSnapshot.Tests.ps1
Outdated
Show resolved
Hide resolved
src/FileShare/FileShare.Autorest/test/Get-AzFileShareSnapshot.Tests.ps1
Outdated
Show resolved
Hide resolved
src/FileShare/FileShare.Autorest/test/FileShare-PrivateEndpoint.Tests.ps1
Show resolved
Hide resolved
src/FileShare/FileShare.Autorest/test/FileShare-PrivateEndpoint.Recording.json
Outdated
Show resolved
Hide resolved
- Add FileShare-PrivateEndpoint tests with full recording (12 tests passing) - Fixed GroupId from 'share' to 'fileshare' for Microsoft.FileShares provider - Tests skip gracefully when Az.Network unavailable (playback mode compatible) - Recording includes VNet, Subnet, FileShare, and Private Endpoint operations - Remove duplicate FileShare-NegativeTests files - Kept FileShare-Negative.Tests.ps1 as single negative test suite - Eliminates test interference and reduces execution time - Fix Get-AzFileShareSnapshot InputObject parameter binding - Cast hashtable to FileShareIdentity model type before passing to -InputObject - Aligns with other test patterns for reliable parameter binding - Remove localEnv.json from tracking - Local environment file should not be committed
Contributor
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
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.
Add prerequisites documentation and installer script for TypeSpec-based FileShare development (PREREQUISITES-STATUS.md, check-and-install-prerequisites.ps1) and add eng package manifest to pull TypeSpec packages. Include generated Pester module files and related test assets for FileShare, plus test environment templates, test helpers, sample implementation, and a test plan/status. Update FileShare project metadata and docs (AssemblyInfo, Az.FileShare.psd1, Az.FileShare.md) and adjust several FileShare test scripts. Also remove obsolete EventGrid generate-info.json.
Description
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:ChangeLog.mdfile(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.## Upcoming Releaseheader in the past tense.ChangeLog.mdif no new release is required, such as fixing test case only.