Skip to content

Commit

Permalink
Forbid the version to be Brave-only (without the Chromium major).
Browse files Browse the repository at this point in the history
  • Loading branch information
goodov committed Oct 25, 2024
1 parent 7252645 commit 34ab7b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
41 changes: 21 additions & 20 deletions src/seed_tools/utils/study_validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,27 +596,28 @@ describe('getStudyErrors', () => {
);
});

test.each([{ min_version: '130.0.6517.0' }, { max_version: '135.0.6707.0' }])(
'should error if version is Chromium %s',
(filter: any) => {
const study = Study.fromJson({
name: 'study',
experiment: [
{
name: 'experiment1',
probability_weight: 100,
},
],
filter,
});
test.each([
{ min_version: '130.0.6517.0' },
{ max_version: '135.0.6707.0' },
{ min_version: '1.65.70' },
])('should error if version is non-Brave %s', (filter: any) => {
const study = Study.fromJson({
name: 'study',
experiment: [
{
name: 'experiment1',
probability_weight: 100,
},
],
filter,
});

expect(
study_validation.getStudyErrors(study, studyFileBaseName),
).toContainEqual(
expect.stringContaining('Detected Chromium version in a filter'),
);
},
);
expect(
study_validation.getStudyErrors(study, studyFileBaseName),
).toContainEqual(
expect.stringContaining('Detected non-Brave version in a filter'),
);
});

test.each([{ min_version: '130.1.70.0' }, { max_version: '135.1.91.0' }])(
'should not error if version is Brave %s',
Expand Down
4 changes: 2 additions & 2 deletions src/seed_tools/utils/study_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ function checkVersionRange(study: Study): string[] {
if (
version !== undefined &&
version.components.length >= 3 &&
version.components[2] > 6000
(version.components[0] < 90 || version.components[2] > 6000)
) {
errors.push(
`Detected Chromium version in a filter for study ${study.name}: ${version.toString()}. Use Brave version in a format CHROMIUM_MAJOR.BRAVE_MAJOR.BRAVE_MINOR.BRAVE_BUILD`,
`Detected non-Brave version in a filter for study ${study.name}: ${version.toString()}. Use Brave version in a format CHROMIUM_MAJOR.BRAVE_MAJOR.BRAVE_MINOR.BRAVE_BUILD`,
);
}
};
Expand Down

0 comments on commit 34ab7b5

Please sign in to comment.