Skip to content

Commit

Permalink
tests: random data can be correct sometimes, fixed tests that failed …
Browse files Browse the repository at this point in the history
…due to this

[ci skip]
  • Loading branch information
tegefaulkes committed May 24, 2024
1 parent eb2c9fe commit dc72c7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions tests/git/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ describe('Git Http', () => {
'agent=git/[email protected]',
]);
});
test.prop([fc.uint8Array({ minLength: 100 })])(
test.prop([fc.uint8Array({ minLength: 100 }).noShrink()])(
'parsePackRequest handles random data',
async (data) => {
await expect(
gitHttp.parsePackRequest([Buffer.from(data)]),
).rejects.toThrow(validationErrors.ErrorParse);
const bufferData = Buffer.from(data);
fc.pre(!/^[0-9a-f]{4}$/.test(bufferData.subarray(0, 4).toString()))
await expect(gitHttp.parsePackRequest([bufferData])).rejects.toThrow(
validationErrors.ErrorParse,
);
},
);
test('generatePackData', async () => {
Expand Down
4 changes: 3 additions & 1 deletion tests/git/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ describe('Git utils', () => {
test.prop([fc.uint8Array({ size: 'medium', minLength: 1 }).noShrink()])(
'parseRequestLine handles bad data',
async (randomData) => {
expect(() => gitUtils.parseRequestLine(Buffer.from(randomData))).toThrow(
const bufferData = Buffer.from(randomData);
fc.pre(!/^[0-9a-f]{4}$/.test(bufferData.subarray(0, 4).toString()))
expect(() => gitUtils.parseRequestLine(bufferData)).toThrow(
validationErrors.ErrorParse,
);
},
Expand Down

0 comments on commit dc72c7c

Please sign in to comment.