test: always mock github check requests
parent
b924651eb9
commit
d6dc078d5a
|
@ -2,7 +2,6 @@ import { BuildParameters } from '../..';
|
||||||
import CloudRunner from '../cloud-runner';
|
import CloudRunner from '../cloud-runner';
|
||||||
import UnityVersioning from '../../unity-versioning';
|
import UnityVersioning from '../../unity-versioning';
|
||||||
import { Cli } from '../../cli/cli';
|
import { Cli } from '../../cli/cli';
|
||||||
import CloudRunnerOptions from '../options/cloud-runner-options';
|
|
||||||
import setups from './cloud-runner-suite.test';
|
import setups from './cloud-runner-suite.test';
|
||||||
import { OptionValues } from 'commander';
|
import { OptionValues } from 'commander';
|
||||||
import GitHub from '../../github';
|
import GitHub from '../../github';
|
||||||
|
@ -16,61 +15,59 @@ describe('Cloud Runner Github Checks', () => {
|
||||||
setups();
|
setups();
|
||||||
it('Responds', () => {});
|
it('Responds', () => {});
|
||||||
|
|
||||||
if (CloudRunnerOptions.cloudRunnerDebug) {
|
beforeEach(() => {
|
||||||
beforeEach(() => {
|
// Mock GitHub API requests to avoid real network calls
|
||||||
// Mock GitHub API requests to avoid real network calls
|
jest.spyOn(GitHub as any, 'createGitHubCheckRequest').mockResolvedValue({
|
||||||
jest.spyOn(GitHub as any, 'createGitHubCheckRequest').mockResolvedValue({
|
status: 201,
|
||||||
status: 201,
|
data: { id: '1' },
|
||||||
data: { id: '1' },
|
|
||||||
});
|
|
||||||
jest.spyOn(GitHub as any, 'updateGitHubCheckRequest').mockResolvedValue({
|
|
||||||
status: 200,
|
|
||||||
data: {},
|
|
||||||
});
|
|
||||||
jest.spyOn(GitHub as any, 'runUpdateAsyncChecksWorkflow').mockResolvedValue(undefined);
|
|
||||||
});
|
});
|
||||||
|
jest.spyOn(GitHub as any, 'updateGitHubCheckRequest').mockResolvedValue({
|
||||||
afterEach(() => {
|
status: 200,
|
||||||
jest.restoreAllMocks();
|
data: {},
|
||||||
});
|
});
|
||||||
|
jest.spyOn(GitHub as any, 'runUpdateAsyncChecksWorkflow').mockResolvedValue(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
it(
|
afterEach(() => {
|
||||||
'Check Handling Direct',
|
jest.restoreAllMocks();
|
||||||
async () => {
|
});
|
||||||
// Setup parameters
|
|
||||||
const buildParameter = await CreateParameters({
|
it(
|
||||||
versioning: 'None',
|
'Check Handling Direct',
|
||||||
projectPath: 'test-project',
|
async () => {
|
||||||
unityVersion: UnityVersioning.read('test-project'),
|
// Setup parameters
|
||||||
asyncCloudRunner: `true`,
|
const buildParameter = await CreateParameters({
|
||||||
githubChecks: `true`,
|
versioning: 'None',
|
||||||
});
|
projectPath: 'test-project',
|
||||||
await CloudRunner.setup(buildParameter);
|
unityVersion: UnityVersioning.read('test-project'),
|
||||||
CloudRunner.buildParameters.githubCheckId = await GitHub.createGitHubCheck(`direct create`);
|
asyncCloudRunner: `true`,
|
||||||
await GitHub.updateGitHubCheck(`1 ${new Date().toISOString()}`, `direct`);
|
githubChecks: `true`,
|
||||||
await GitHub.updateGitHubCheck(`2 ${new Date().toISOString()}`, `direct`, `success`, `completed`);
|
});
|
||||||
},
|
await CloudRunner.setup(buildParameter);
|
||||||
TIMEOUT_INFINITE,
|
CloudRunner.buildParameters.githubCheckId = await GitHub.createGitHubCheck(`direct create`);
|
||||||
);
|
await GitHub.updateGitHubCheck(`1 ${new Date().toISOString()}`, `direct`);
|
||||||
it(
|
await GitHub.updateGitHubCheck(`2 ${new Date().toISOString()}`, `direct`, `success`, `completed`);
|
||||||
'Check Handling Via Async Workflow',
|
},
|
||||||
async () => {
|
TIMEOUT_INFINITE,
|
||||||
// Setup parameters
|
);
|
||||||
const buildParameter = await CreateParameters({
|
it(
|
||||||
versioning: 'None',
|
'Check Handling Via Async Workflow',
|
||||||
projectPath: 'test-project',
|
async () => {
|
||||||
unityVersion: UnityVersioning.read('test-project'),
|
// Setup parameters
|
||||||
asyncCloudRunner: `true`,
|
const buildParameter = await CreateParameters({
|
||||||
githubChecks: `true`,
|
versioning: 'None',
|
||||||
});
|
projectPath: 'test-project',
|
||||||
GitHub.forceAsyncTest = true;
|
unityVersion: UnityVersioning.read('test-project'),
|
||||||
await CloudRunner.setup(buildParameter);
|
asyncCloudRunner: `true`,
|
||||||
CloudRunner.buildParameters.githubCheckId = await GitHub.createGitHubCheck(`async create`);
|
githubChecks: `true`,
|
||||||
await GitHub.updateGitHubCheck(`1 ${new Date().toISOString()}`, `async`);
|
});
|
||||||
await GitHub.updateGitHubCheck(`2 ${new Date().toISOString()}`, `async`, `success`, `completed`);
|
GitHub.forceAsyncTest = true;
|
||||||
GitHub.forceAsyncTest = false;
|
await CloudRunner.setup(buildParameter);
|
||||||
},
|
CloudRunner.buildParameters.githubCheckId = await GitHub.createGitHubCheck(`async create`);
|
||||||
TIMEOUT_INFINITE,
|
await GitHub.updateGitHubCheck(`1 ${new Date().toISOString()}`, `async`);
|
||||||
);
|
await GitHub.updateGitHubCheck(`2 ${new Date().toISOString()}`, `async`, `success`, `completed`);
|
||||||
}
|
GitHub.forceAsyncTest = false;
|
||||||
|
},
|
||||||
|
TIMEOUT_INFINITE,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue