-
Notifications
You must be signed in to change notification settings - Fork 66
add nested test cases for client-initialization #3697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add nested test cases for client-initialization #3697
Conversation
|
All changed packages have been documented.
|
commit: |
|
You can try these changes here
|
…/kazrael2119/typespec-azure into nested-test-cases-for-clientinit
...e-http-specs/specs/azure/client-generator-core/client-initialization/individually/client.tsp
Outdated
Show resolved
Hide resolved
...-specs/specs/azure/client-generator-core/client-initialization/individuallyParent/client.tsp
Outdated
Show resolved
Hide resolved
...e-http-specs/specs/azure/client-generator-core/client-initialization/individually/client.tsp
Show resolved
Hide resolved
...ure-http-specs/specs/azure/client-generator-core/client-initialization/individually/main.tsp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors the client-initialization test cases from a flat structure into a nested directory structure, adding comprehensive test coverage for different client initialization patterns. The changes address issue #3405 by organizing test scenarios into three distinct categories: default, individually, and individuallyParent initialization behaviors.
Changes:
- Removed the monolithic
mockapi.tsfile and reorganized test cases into three subdirectories - Added new test scenarios for individually-initialized and individually-parent-initialized clients
- Updated routing paths and namespace definitions to reflect the new nested structure
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/mockapi.ts | Deleted the original flat mockapi.ts file |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/default/mockapi.ts | Created mock API definitions for default client initialization scenarios |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/default/main.tsp | Added service interface definitions for default initialization patterns |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/default/client.tsp | Defined client interfaces with default initialization behavior, including new QueryParam scenario |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individually/mockapi.ts | Created mock API definitions for individually-initialized client scenarios |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individually/main.tsp | Added service interface definitions for individual initialization patterns |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individually/client.tsp | Defined client interfaces with individually initialization behavior |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individuallyParent/mockapi.ts | Created mock API definitions for individually-parent-initialized client scenarios |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individuallyParent/main.tsp | Added service interface definitions for individually-parent initialization patterns |
| packages/azure-http-specs/specs/azure/client-generator-core/client-initialization/individuallyParent/client.tsp | Defined client interfaces with both individual and parent initialization behavior (incomplete - missing ParamAlias scenario) |
| .chronus/changes/nested-test-cases-for-clientinit-2025-11-25-9-26-9.md | Added changelog entry documenting the fix |
| request: { | ||
| query: { | ||
| blobName: "test-blob", | ||
| format: "text", |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mock API expects both blobName and format query parameters in the delete request, but the TypeSpec definition for deleteStandalone only specifies ...DefaultQueryParam (which only includes blobName). The format parameter should either be added to the TypeSpec definition or removed from the mock API request.
| format: "text", |
|
|
||
| // Mock responses for IndividuallyParentNestedWithParamAliasClient scenario | ||
| Scenarios.Azure_ClientGenerator_Core_ClientInitialization_IndividuallyParentClient_IndividuallyParent_IndividuallyParentNestedWithParamAliasClient = | ||
| passOnSuccess([ | ||
| { | ||
| uri: "/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/sample-blob/with-aliased-name", | ||
| method: "get", | ||
| request: {}, | ||
| response: { | ||
| status: 204, | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }, | ||
| { | ||
| uri: "/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/sample-blob/with-original-name", | ||
| method: "get", | ||
| request: {}, | ||
| response: { | ||
| status: 204, | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }, | ||
| ]); |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A mock API scenario is defined for IndividuallyParentNestedWithParamAliasClient but there is no corresponding client interface definition in the client.tsp file. This scenario needs to be added to match the mock API and main.tsp service interface NestedDefaultIndividuallyParentParamAlias.
| // Mock responses for IndividuallyParentNestedWithParamAliasClient scenario | |
| Scenarios.Azure_ClientGenerator_Core_ClientInitialization_IndividuallyParentClient_IndividuallyParent_IndividuallyParentNestedWithParamAliasClient = | |
| passOnSuccess([ | |
| { | |
| uri: "/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/sample-blob/with-aliased-name", | |
| method: "get", | |
| request: {}, | |
| response: { | |
| status: 204, | |
| }, | |
| kind: "MockApiDefinition", | |
| }, | |
| { | |
| uri: "/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/sample-blob/with-original-name", | |
| method: "get", | |
| request: {}, | |
| response: { | |
| status: 204, | |
| }, | |
| kind: "MockApiDefinition", | |
| }, | |
| ]); |
|
I've requested Copilot review. If comment is not valid, feel free to resolve them. |
| blobName: string; | ||
| } | ||
|
|
||
| model DefaultQueryParamClientOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonder why do we need Default prefix here but not for other ClientOptions?
| name: string; | ||
| } | ||
|
|
||
| model DefaultQueryParam { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call it BlobQueryParam?
| @global.Azure.ClientGenerator.Core.clientInitialization({ | ||
| parameters: DefaultQueryParamClientOptions, | ||
| }) | ||
| @route("/query") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to define the @route again?
| ``` | ||
| """) | ||
| @scenario | ||
| @global.Azure.ClientGenerator.Core.client({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use @@global.Azure.ClientGenerator.Core.client(Service.QueryParam, {name: "QueryParamClient", service: Service})?
fixes Azure/autorest.typescript#3405