-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/security-only-updates
- Loading branch information
Showing
39 changed files
with
788 additions
and
239 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
|
@@ -36,13 +36,13 @@ jobs: | |
fetch-depth: 0 # Required for GitVersion | ||
|
||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected].0 | ||
uses: gittools/actions/gitversion/[email protected].1 | ||
with: | ||
versionSpec: '6.x' | ||
|
||
- name: Determine Version | ||
id: gitversion | ||
uses: gittools/actions/gitversion/[email protected].0 | ||
uses: gittools/actions/gitversion/[email protected].1 | ||
with: | ||
useConfigFile: true | ||
|
||
|
This file contains 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 |
---|---|---|
|
@@ -40,20 +40,20 @@ jobs: | |
fetch-depth: 0 # Required for GitVersion | ||
|
||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected].0 | ||
uses: gittools/actions/gitversion/[email protected].1 | ||
with: | ||
versionSpec: '6.x' | ||
|
||
- name: Determine Version | ||
uses: gittools/actions/gitversion/[email protected].0 | ||
uses: gittools/actions/gitversion/[email protected].1 | ||
id: gitversion | ||
with: | ||
useConfigFile: true | ||
|
||
- name: Setup .NET SDK | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.x' | ||
dotnet-version: '9.x' | ||
|
||
- name: Test | ||
run: dotnet test -c Release --collect "Code coverage" | ||
|
This file contains 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 |
---|---|---|
|
@@ -35,6 +35,7 @@ jobs: | |
- { ecosystem: cargo } | ||
- { ecosystem: composer } | ||
- { ecosystem: docker } | ||
- { ecosystem: dotnet-sdk } | ||
- { ecosystem: elm } | ||
- { ecosystem: gitsubmodule } | ||
- { ecosystem: github-actions } | ||
|
@@ -63,12 +64,12 @@ jobs: | |
fetch-depth: 0 # Required for GitVersion | ||
|
||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected].0 | ||
uses: gittools/actions/gitversion/[email protected].1 | ||
with: | ||
versionSpec: '6.x' | ||
|
||
- name: Determine Version | ||
uses: gittools/actions/gitversion/[email protected].0 | ||
uses: gittools/actions/gitversion/[email protected].1 | ||
id: gitversion | ||
with: | ||
useConfigFile: true | ||
|
This file contains 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,2 @@ | ||
pretty-quick --staged | ||
codespell |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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
95 changes: 95 additions & 0 deletions
95
extension/tasks/dependabotV2/utils/azure-devops/AzureDevOpsWebApiClient.test.ts
This file contains 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,95 @@ | ||
import { jest } from '@jest/globals'; | ||
|
||
import { VersionControlChangeType } from 'azure-devops-node-api/interfaces/TfvcInterfaces'; | ||
|
||
import { AzureDevOpsWebApiClient } from './AzureDevOpsWebApiClient'; | ||
import { ICreatePullRequest } from './interfaces/IPullRequest'; | ||
import exp = require('constants'); | ||
|
||
jest.mock('azure-devops-node-api'); | ||
jest.mock('azure-pipelines-task-lib/task'); | ||
|
||
describe('AzureDevOpsWebApiClient', () => { | ||
const organisationApiUrl = 'https://dev.azure.com/mock-organization'; | ||
const accessToken = 'mock-access-token'; | ||
let client: AzureDevOpsWebApiClient; | ||
|
||
beforeEach(() => { | ||
client = new AzureDevOpsWebApiClient(organisationApiUrl, accessToken); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('createPullRequest', () => { | ||
let pr: ICreatePullRequest; | ||
|
||
beforeEach(() => { | ||
pr = { | ||
project: 'project', | ||
repository: 'repository', | ||
source: { | ||
branch: 'update-branch', | ||
commit: 'commit-id', | ||
}, | ||
target: { | ||
branch: 'main', | ||
}, | ||
title: 'PR Title', | ||
description: 'PR Description', | ||
commitMessage: 'Commit Message', | ||
changes: [ | ||
{ | ||
path: 'file.txt', | ||
content: 'hello world', | ||
encoding: 'utf-8', | ||
changeType: VersionControlChangeType.Add, | ||
}, | ||
], | ||
}; | ||
}); | ||
|
||
it('should create a pull request without duplicate reviewer and assignee identities', async () => { | ||
// Arange | ||
const mockGetUserId = jest.spyOn(client, 'getUserId').mockResolvedValue('my-user-id'); | ||
const mockResolveIdentityId = jest | ||
.spyOn(client, 'resolveIdentityId') | ||
.mockImplementation(async (identity?: string) => { | ||
return identity || ''; | ||
}); | ||
const mockRestApiPost = jest | ||
.spyOn(client as any, 'restApiPost') | ||
.mockResolvedValueOnce({ | ||
commits: [{ commitId: 'new-commit-id' }], | ||
}) | ||
.mockResolvedValueOnce({ | ||
pullRequestId: 1, | ||
}); | ||
const mockRestApiPatch = jest.spyOn(client as any, 'restApiPatch').mockResolvedValueOnce({ | ||
count: 1, | ||
}); | ||
|
||
// Act | ||
pr.assignees = ['user1', 'user2']; | ||
pr.reviewers = ['user1', 'user3']; | ||
const pullRequestId = await client.createPullRequest(pr); | ||
|
||
// Assert | ||
expect(mockRestApiPost).toHaveBeenCalledTimes(2); | ||
expect((mockRestApiPost.mock.calls[1] as any)[1].reviewers.length).toBe(3); | ||
expect((mockRestApiPost.mock.calls[1] as any)[1].reviewers).toContainEqual({ | ||
id: 'user1', | ||
isRequired: true, | ||
isFlagged: true, | ||
}); | ||
expect((mockRestApiPost.mock.calls[1] as any)[1].reviewers).toContainEqual({ | ||
id: 'user2', | ||
isRequired: true, | ||
isFlagged: true, | ||
}); | ||
expect((mockRestApiPost.mock.calls[1] as any)[1].reviewers).toContainEqual({ id: 'user3' }); | ||
expect(pullRequestId).toBe(1); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.