-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Improve test coverage to ~100% for @azure-rest/core-client #38177
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
Merged
deyaaeldeen
merged 17 commits into
main
from
deyaaeldeen/core-client-rest-test-coverage
Apr 21, 2026
Merged
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7c77c9f
Improve test coverage to ~100% for @azure/core-client-rest
8dd12fa
Strengthen isDefined-only assertions with value checks
073e245
Format clientHelpers.spec.ts
5f6a356
Improve operationOptionsToRequestParameters test to exercise requestO…
d3eaa17
test(core-client-rest): remove redundant strictEqual assertions after…
008fdce
fix: remove getCachedDefaultHttpsClient test (function removed in main)
07cec13
fix: fix misleading test name and weak assertions in getClient tests
643d0bf
fix: strengthen stream error tests and fix misleading test name
03c8634
fix: strengthen assertions in core-client-rest tests
4219a8f
refactor: modernize error assertions and spy patterns in core-client-…
Copilot 3715d87
refactor: second pass modernization in core-client-rest tests
d0f67de
refactor: replace PipelineRequest casts with createPipelineRequest in…
e9f044e
Eliminate unnecessary type casts in core-client-rest tests
beeac1c
fix: resolve TS compilation errors in core-client-rest tests
18ad75e
fix: format getClient.spec.ts
d0db843
Strengthen assertions in getClient onResponse test
03810f9
Use assert.isNotEmpty for consistency
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
31 changes: 31 additions & 0 deletions
31
sdk/core/core-client-rest/test/internal/keyCredentialAuthenticationPolicy.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { describe, it, assert } from "vitest"; | ||
| import { | ||
| keyCredentialAuthenticationPolicy, | ||
| keyCredentialAuthenticationPolicyName, | ||
| } from "../../src/keyCredentialAuthenticationPolicy.js"; | ||
| import { createHttpHeaders, createPipelineRequest } from "@azure/core-rest-pipeline"; | ||
|
|
||
| describe("keyCredentialAuthenticationPolicy", () => { | ||
| it("should set the api key header on the request", async () => { | ||
| const credential = { key: "test-api-key" }; | ||
| const headerName = "x-api-key"; | ||
| const policy = keyCredentialAuthenticationPolicy(credential, headerName); | ||
|
|
||
| assert.equal(policy.name, keyCredentialAuthenticationPolicyName); | ||
|
|
||
| const request = createPipelineRequest({ | ||
| url: "https://example.org", | ||
| headers: createHttpHeaders(), | ||
| }); | ||
|
|
||
| const response = await policy.sendRequest(request, async (req) => { | ||
| assert.equal(req.headers.get(headerName), "test-api-key"); | ||
| return { headers: createHttpHeaders(), status: 200, request: req }; | ||
| }); | ||
|
|
||
| assert.equal(response.status, 200); | ||
| }); | ||
| }); |
23 changes: 23 additions & 0 deletions
23
sdk/core/core-client-rest/test/internal/operationOptionHelpers.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { describe, it, assert } from "vitest"; | ||
| import { operationOptionsToRequestParameters } from "../../src/operationOptionHelpers.js"; | ||
|
|
||
| describe("operationOptionsToRequestParameters", () => { | ||
| it("should convert empty operation options to request parameters", () => { | ||
| const result = operationOptionsToRequestParameters({}); | ||
| assert.isDefined(result); | ||
| assert.isUndefined(result.abortSignal); | ||
| assert.isUndefined(result.onResponse); | ||
| assert.isObject(result); | ||
| }); | ||
|
|
||
| it("should pass through abort signal", () => { | ||
| const abortController = new AbortController(); | ||
| const result = operationOptionsToRequestParameters({ | ||
| abortSignal: abortController.signal, | ||
| }); | ||
| assert.equal(result.abortSignal, abortController.signal); | ||
| }); | ||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.