Skip to content

Commit 8c6dd9a

Browse files
committed
test-variation. build stop after merge added
1 parent 6178439 commit 8c6dd9a

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

src/test-variations/test-variations.service.spec.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const initModule = async ({
2222
baselineDeleteMock = jest.fn(),
2323
projectFindOneMock = jest.fn(),
2424
buildCreateMock = jest.fn(),
25+
buildStopMock = jest.fn(),
2526
testRunCreateMock = jest.fn(),
2627
testRunFindMany = jest.fn(),
2728
testRunDeleteMock = jest.fn(),
@@ -40,6 +41,7 @@ const initModule = async ({
4041
provide: BuildsService,
4142
useValue: {
4243
create: buildCreateMock,
44+
stop: buildStopMock,
4345
},
4446
},
4547
{
@@ -140,10 +142,7 @@ describe('TestVariationsService', () => {
140142
createdAt: new Date(),
141143
updatedAt: new Date(),
142144
};
143-
const variationFindManyMock = jest
144-
.fn()
145-
.mockResolvedValueOnce([variationMock])
146-
.mockResolvedValueOnce([undefined]);
145+
const variationFindManyMock = jest.fn().mockResolvedValueOnce([variationMock]).mockResolvedValueOnce([undefined]);
147146
const projectFindOneMock = jest.fn().mockReturnValueOnce(projectMock);
148147
service = await initModule({ variationFindManyMock, projectFindOneMock });
149148

@@ -203,10 +202,7 @@ describe('TestVariationsService', () => {
203202
createdAt: new Date(),
204203
updatedAt: new Date(),
205204
};
206-
const variationFindManyMock = jest
207-
.fn()
208-
.mockResolvedValueOnce([undefined])
209-
.mockResolvedValueOnce([variationMock]);
205+
const variationFindManyMock = jest.fn().mockResolvedValueOnce([undefined]).mockResolvedValueOnce([variationMock]);
210206
const projectFindOneMock = jest.fn().mockReturnValueOnce(projectMock);
211207
service = await initModule({ variationFindManyMock, projectFindOneMock });
212208

@@ -251,10 +247,7 @@ describe('TestVariationsService', () => {
251247
branchName: 'develop',
252248
};
253249

254-
const variationFindManyMock = jest
255-
.fn()
256-
.mockResolvedValueOnce([undefined])
257-
.mockResolvedValueOnce([undefined]);
250+
const variationFindManyMock = jest.fn().mockResolvedValueOnce([undefined]).mockResolvedValueOnce([undefined]);
258251
const projectFindOneMock = jest.fn().mockReturnValueOnce(projectMock);
259252
const variationCreateMock = jest.fn();
260253
service = await initModule({ variationFindManyMock, projectFindOneMock, variationCreateMock });
@@ -415,19 +408,17 @@ describe('TestVariationsService', () => {
415408
width: 10,
416409
height: 10,
417410
});
418-
const getImageMock = jest
419-
.fn()
420-
.mockReturnValueOnce(image)
421-
.mockReturnValueOnce(image)
422-
.mockReturnValueOnce(null);
411+
const getImageMock = jest.fn().mockReturnValueOnce(image).mockReturnValueOnce(image).mockReturnValueOnce(null);
423412
const findOrCreateMock = jest
424413
.fn()
425414
.mockResolvedValueOnce(testVariationMainBranch)
426415
.mockResolvedValueOnce(testVariationMainBranch);
427416
const testRunCreateMock = jest.fn();
417+
const buildStopMock = jest.fn();
428418
const service = await initModule({
429419
projectFindOneMock,
430420
buildCreateMock,
421+
buildStopMock,
431422
testRunCreateMock,
432423
variationFindManyMock,
433424
getImageMock,
@@ -454,7 +445,7 @@ describe('TestVariationsService', () => {
454445
branchName: project.mainBranchName,
455446
});
456447

457-
await new Promise(r => setTimeout(r, 1));
448+
await new Promise((r) => setTimeout(r, 1));
458449
expect(testRunCreateMock).toHaveBeenNthCalledWith(1, testVariationMainBranch, {
459450
...testVariation,
460451
buildId: build.id,
@@ -470,6 +461,7 @@ describe('TestVariationsService', () => {
470461
merge: true,
471462
});
472463
expect(testRunCreateMock).toHaveBeenCalledTimes(2);
464+
expect(buildStopMock).toHaveBeenCalledWith(build.id);
473465
});
474466

475467
it('delete', async () => {

src/test-variations/test-variations.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ export class TestVariationsService {
139139
}
140140
});
141141

142-
return build;
142+
// stop build
143+
return this.buildsService.stop(build.id);
143144
}
144145

145146
async delete(id: string): Promise<TestVariation> {

0 commit comments

Comments
 (0)