Fix attachment downloads for zero cdnId

This commit is contained in:
Fedor Indutny 2021-07-09 13:12:29 -07:00 committed by GitHub
parent ddbbe3a6b1
commit e4efa01073
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -3,6 +3,7 @@
/* eslint-disable no-restricted-syntax */
import { assert } from 'chai';
import Long from 'long';
import {
processDataMessage,
@ -49,6 +50,24 @@ describe('processDataMessage', () => {
assert.deepStrictEqual(out.attachments, [PROCESSED_ATTACHMENT]);
});
it('should process attachments with 0 cdnId', async () => {
const out = await check({
attachments: [
{
...UNPROCESSED_ATTACHMENT,
cdnId: new Long(0),
},
],
});
assert.deepStrictEqual(out.attachments, [
{
...PROCESSED_ATTACHMENT,
cdnId: undefined,
},
]);
});
it('should throw on too many attachments', async () => {
const attachments: Array<Proto.IAttachmentPointer> = [];
for (let i = 0; i < ATTACHMENT_MAX + 1; i += 1) {