From 5b2ef127c86d77c0780f24f1581ae6bac76b329b Mon Sep 17 00:00:00 2001 From: Charis Kyriakou Date: Wed, 19 Oct 2022 10:02:31 +0100 Subject: [PATCH] Add GitHub API requests that will be mocked --- .../ql-vscode/src/mocks/gh-api-request.ts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 extensions/ql-vscode/src/mocks/gh-api-request.ts diff --git a/extensions/ql-vscode/src/mocks/gh-api-request.ts b/extensions/ql-vscode/src/mocks/gh-api-request.ts new file mode 100644 index 00000000000..0f322f990fd --- /dev/null +++ b/extensions/ql-vscode/src/mocks/gh-api-request.ts @@ -0,0 +1,55 @@ +import { Repository } from '../remote-queries/gh-api/repository'; +import { VariantAnalysis, VariantAnalysisRepoTask } from '../remote-queries/gh-api/variant-analysis'; + +// Types that represent requests/responses from the GitHub API +// that we need to mock. + +export enum RequestKind { + GetRepo = 'getRepo', + SubmitVariantAnalysis = 'submitVariantAnalysis', + GetVariantAnalysis = 'getVariantAnalysis', + GetVariantAnalysisRepo = 'getVariantAnalysisRepo', + GetVariantAnalysisRepoResult = 'getVariantAnalysisRepoResult', +} + +export interface GetRepoRequest { + request: { + kind: RequestKind.GetRepo + }, + response: { + status: number, + body: Repository + } +} + +export interface GetVariantAnalysisRequest { + request: { + kind: RequestKind.GetVariantAnalysis + }, + response: { + status: number, + body: VariantAnalysis + } +} + +export interface GetVariantAnalysisRepoRequest { + request: { + kind: RequestKind.GetVariantAnalysisRepo, + repositoryId: number + }, + response: { + status: number, + body: VariantAnalysisRepoTask + } +} + +export interface GetVariantAnalysisRepoResultRequest { + request: { + kind: RequestKind.GetVariantAnalysisRepoResult, + repositoryId: number + }, + response: { + status: number, + body: ArrayBuffer + } +}