8b01d42e5d
Adds a new folder to dev-infra where shared testing utilities could be placed in. This commit already adds initial testing utilities for dealing with the `GitClient` and SemVer versions. The `GitClient` in the testing utilities simulates actual Git behavior in a virtual manner. It's not complete at all, but can be extended based on our needs. The currently implemented commands are the most basic ones that we'd need for our release tooling. PR Close #38656
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {GithubRepo} from '../git/github';
|
|
|
|
import {Commit} from './virtual-git-client';
|
|
|
|
/** Interface describing the match parameters for a virtual Git client push. */
|
|
interface BranchPushMatchParameters {
|
|
targetRepo: GithubRepo;
|
|
targetBranch: string;
|
|
baseRepo: GithubRepo;
|
|
baseBranch: string;
|
|
expectedCommits: Commit[]|jasmine.ArrayContaining<Commit>;
|
|
}
|
|
|
|
/**
|
|
* Gets a jasmine object matcher for asserting that a virtual Git client push
|
|
* matches the specified branch push (through the match parameters).
|
|
*/
|
|
export function getBranchPushMatcher(options: BranchPushMatchParameters) {
|
|
const {targetRepo, targetBranch, baseBranch, baseRepo, expectedCommits} = options;
|
|
return jasmine.objectContaining({
|
|
remote: {
|
|
repoUrl: `https://github.com/${targetRepo.owner}/${targetRepo.name}.git`,
|
|
name: `refs/heads/${targetBranch}`
|
|
},
|
|
head: jasmine.objectContaining({
|
|
newCommits: expectedCommits,
|
|
ref: {
|
|
repoUrl: `https://github.com/${baseRepo.owner}/${baseRepo.name}.git`,
|
|
name: baseBranch,
|
|
},
|
|
})
|
|
});
|
|
}
|