From 132abc3788ea36670a4fdd799aa7503bd2199678 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 09:16:05 +0000 Subject: [PATCH] feat: implement Azure_SpecialHeaders_ConditionalRequest test Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/3df6a0b2-f2b1-4ce5-90d1-2dfcecb666e3 Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> --- ...reSpecialHeadersConditionalRequest.spec.ts | 44 +++++++++++++++++++ .../conditional-request/.gitignore | 6 +++ .../conditional-request/src/index.d.ts | 40 +++++++++++++++++ .../conditional-request/tspconfig.yaml | 13 ++++++ .../test/commands/cadl-ranch-list.js | 4 ++ 5 files changed, 107 insertions(+) create mode 100644 packages/typespec-ts/test/azureModularIntegration/azureSpecialHeadersConditionalRequest.spec.ts create mode 100644 packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/.gitignore create mode 100644 packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/src/index.d.ts create mode 100644 packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/tspconfig.yaml diff --git a/packages/typespec-ts/test/azureModularIntegration/azureSpecialHeadersConditionalRequest.spec.ts b/packages/typespec-ts/test/azureModularIntegration/azureSpecialHeadersConditionalRequest.spec.ts new file mode 100644 index 0000000000..31136abed8 --- /dev/null +++ b/packages/typespec-ts/test/azureModularIntegration/azureSpecialHeadersConditionalRequest.spec.ts @@ -0,0 +1,44 @@ +import { assert, describe, it, beforeEach } from "vitest"; +import { ConditionalRequestClient } from "./generated/azure/special-headers/conditional-request/src/index.js"; + +describe("Azure_SpecialHeaders_ConditionalRequest", () => { + let client: ConditionalRequestClient; + + beforeEach(() => { + client = new ConditionalRequestClient({ + endpoint: "http://localhost:3002", + allowInsecureConnection: true, + retryOptions: { + maxRetries: 0 + } + }); + }); + + it("should send the If-Match header", async () => { + await client.postIfMatch({ + ifMatch: `"valid"` + }); + assert.ok(true); + }); + + it("should send the If-None-Match header", async () => { + await client.postIfNoneMatch({ + ifNoneMatch: `"invalid"` + }); + assert.ok(true); + }); + + it("should send the custom x-ms-blob-if-match header", async () => { + await client.postCustomIfMatch({ + ifMatch: `"valid"` + }); + assert.ok(true); + }); + + it("should send the custom x-ms-blob-if-none-match header", async () => { + await client.postCustomIfNoneMatch({ + ifNoneMatch: `"invalid"` + }); + assert.ok(true); + }); +}); diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/.gitignore b/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/.gitignore new file mode 100644 index 0000000000..39220655cc --- /dev/null +++ b/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/.gitignore @@ -0,0 +1,6 @@ +/** +!/src +/src/** +!/src/index.d.ts +!/.gitignore +!/tspconfig.yaml diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/src/index.d.ts b/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/src/index.d.ts new file mode 100644 index 0000000000..ea875c6820 --- /dev/null +++ b/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/src/index.d.ts @@ -0,0 +1,40 @@ +import { ClientOptions } from '@azure-rest/core-client'; +import { isRestError } from '@azure/core-rest-pipeline'; +import { OperationOptions } from '@azure-rest/core-client'; +import { Pipeline } from '@azure/core-rest-pipeline'; +import { RestError } from '@azure/core-rest-pipeline'; + +export declare class ConditionalRequestClient { + private _client; + readonly pipeline: Pipeline; + constructor(options?: ConditionalRequestClientOptionalParams); + postCustomIfNoneMatch(options?: PostCustomIfNoneMatchOptionalParams): Promise; + postCustomIfMatch(options?: PostCustomIfMatchOptionalParams): Promise; + postIfNoneMatch(options?: PostIfNoneMatchOptionalParams): Promise; + postIfMatch(options?: PostIfMatchOptionalParams): Promise; +} + +export declare interface ConditionalRequestClientOptionalParams extends ClientOptions { +} + +export { isRestError } + +export declare interface PostCustomIfMatchOptionalParams extends OperationOptions { + ifMatch?: string; +} + +export declare interface PostCustomIfNoneMatchOptionalParams extends OperationOptions { + ifNoneMatch?: string; +} + +export declare interface PostIfMatchOptionalParams extends OperationOptions { + ifMatch?: string; +} + +export declare interface PostIfNoneMatchOptionalParams extends OperationOptions { + ifNoneMatch?: string; +} + +export { RestError } + +export { } diff --git a/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/tspconfig.yaml b/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/tspconfig.yaml new file mode 100644 index 0000000000..7adebb8b6d --- /dev/null +++ b/packages/typespec-ts/test/azureModularIntegration/generated/azure/special-headers/conditional-request/tspconfig.yaml @@ -0,0 +1,13 @@ +emit: + - "@azure-tools/typespec-ts" +options: + "@azure-tools/typespec-ts": + emitter-output-dir: "{project-root}" + generate-test: false + add-credentials: false + flavor: azure + azure-sdk-for-js: false + is-typespec-test: true + package-details: + name: "@msinternal/azure-special-headers-conditional-request" + description: "Azure Special Headers Conditional Request Test Service" diff --git a/packages/typespec-ts/test/commands/cadl-ranch-list.js b/packages/typespec-ts/test/commands/cadl-ranch-list.js index 048fb40f0b..959abbf291 100644 --- a/packages/typespec-ts/test/commands/cadl-ranch-list.js +++ b/packages/typespec-ts/test/commands/cadl-ranch-list.js @@ -659,6 +659,10 @@ export const azureModularTsps = [ outputPath: "azure/special-headers/client-request-id", inputPath: "azure/special-headers/client-request-id" }, + { + outputPath: "azure/special-headers/conditional-request", + inputPath: "azure/special-headers/conditional-request" + }, { outputPath: "parameters/collection-format", inputPath: "parameters/collection-format"