Last active
July 29, 2019 18:12
-
-
Save TsuyoshiUshio/ead8a011fd50c9dc93ce0b13834ac2f8 to your computer and use it in GitHub Desktop.
Mock target class
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
| import * as tl from 'azure-pipelines-task-lib'; | |
| import * as wa from "azure-devops-node-api/WebApi"; | |
| import * as GitInterfaces from "azure-devops-node-api/interfaces/GitInterfaces"; | |
| import VariableResolver from './variableresolver'; | |
| import { IGitApi, GitApi } from 'azure-devops-node-api/GitApi'; | |
| export interface IClientFactory { | |
| create(pat:string): Promise<IGitApi>; | |
| } | |
| class ClientFactory implements IClientFactory { | |
| public async create(pat:string): Promise<IGitApi> { | |
| let credHandler = wa.getPersonalAccessTokenHandler(pat); | |
| let connection = new wa.WebApi(tl.getVariable('System.TeamFoundationCollectionUri'), credHandler); | |
| return await connection.getGitApi(); | |
| } | |
| } | |
| export class CreatePRCommentTask { | |
| factory: IClientFactory; | |
| constructor(clientFactory: IClientFactory) { | |
| this.factory = clientFactory; | |
| } | |
| : | |
| new CreatePRCommentTask(new ClientFactory()).run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment