Skip to content

Commit bdc04d1

Browse files
committed
use baselineBranchName to find testVariation in postTestRun
1 parent 1d60fbb commit bdc04d1

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/builds/dto/build-create.dto.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export class CreateBuildDto {
1414
@IsNotEmpty()
1515
readonly branchName?: string;
1616

17+
@ApiPropertyOptional()
18+
@IsOptional()
19+
@IsString()
20+
readonly baselineBranchName?: string;
21+
1722
@ApiProperty()
1823
@IsString()
1924
readonly project: string;

src/test-runs/dto/create-test-request.dto.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export class CreateTestRequestDto extends BaselineDataDto {
1414
@IsUUID()
1515
projectId: string;
1616

17+
@ApiPropertyOptional()
18+
@IsOptional()
19+
@IsString()
20+
baselineBranchName?: string;
21+
1722
@ApiPropertyOptional()
1823
@IsOptional()
1924
@IsNumber()

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,20 @@ export class TestVariationsService {
8080
* @returns
8181
*/
8282
async find(
83-
createTestRequestDto: BaselineDataDto & { projectId: string; sourceBranch?: string }
83+
createTestRequestDto: BaselineDataDto & { projectId: string; baselineBranchName?: string }
8484
): Promise<TestVariation | null> {
8585
const project = await this.prismaService.project.findUnique({ where: { id: createTestRequestDto.projectId } });
86-
const mainBranch = createTestRequestDto.sourceBranch ?? project.mainBranchName;
86+
const baselineBranchName = createTestRequestDto.baselineBranchName ?? project.mainBranchName;
8787

88-
const [mainBranchTestVariation, currentBranchTestVariation] = await Promise.all([
88+
const [baselineBranchTestVariation, currentBranchTestVariation] = await Promise.all([
8989
// search main branch variation
9090
this.findUnique({
9191
projectId: createTestRequestDto.projectId,
92-
branchName: mainBranch,
92+
branchName: baselineBranchName,
9393
...getTestVariationUniqueData(createTestRequestDto),
9494
}),
9595
// search current branch variation
96-
createTestRequestDto.branchName !== mainBranch &&
96+
createTestRequestDto.branchName !== baselineBranchName &&
9797
this.findUnique({
9898
projectId: createTestRequestDto.projectId,
9999
branchName: createTestRequestDto.branchName,
@@ -102,14 +102,14 @@ export class TestVariationsService {
102102
]);
103103

104104
if (!!currentBranchTestVariation) {
105-
if (mainBranchTestVariation && mainBranchTestVariation.updatedAt > currentBranchTestVariation.updatedAt) {
106-
return mainBranchTestVariation;
105+
if (baselineBranchTestVariation && baselineBranchTestVariation.updatedAt > currentBranchTestVariation.updatedAt) {
106+
return baselineBranchTestVariation;
107107
}
108108
return currentBranchTestVariation;
109109
}
110110

111-
if (!!mainBranchTestVariation) {
112-
return mainBranchTestVariation;
111+
if (!!baselineBranchTestVariation) {
112+
return baselineBranchTestVariation;
113113
}
114114
}
115115

0 commit comments

Comments
 (0)