Repair broken attachments with non-array 'data' fields
This commit is contained in:
parent
a0424be5bb
commit
2f252b8e26
10 changed files with 105 additions and 34 deletions
|
@ -396,6 +396,7 @@ describe('Attachment', () => {
|
|||
|
||||
const actual = await Attachment.migrateDataToFileSystem(input, {
|
||||
writeNewAttachmentData,
|
||||
logger,
|
||||
});
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
@ -417,11 +418,12 @@ describe('Attachment', () => {
|
|||
|
||||
const actual = await Attachment.migrateDataToFileSystem(input, {
|
||||
writeNewAttachmentData,
|
||||
logger,
|
||||
});
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should throw error if data is not valid', async () => {
|
||||
it('should clear `data` field if it is not a typed array', async () => {
|
||||
const input = {
|
||||
contentType: MIME.IMAGE_JPEG,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
@ -432,12 +434,12 @@ describe('Attachment', () => {
|
|||
|
||||
const writeNewAttachmentData = async () => 'abc/abcdefgh123456789';
|
||||
|
||||
await assert.isRejected(
|
||||
Attachment.migrateDataToFileSystem(input, {
|
||||
writeNewAttachmentData,
|
||||
}),
|
||||
'Expected `attachment.data` to be a typed array; got: number'
|
||||
);
|
||||
const actual = await Attachment.migrateDataToFileSystem(input, {
|
||||
writeNewAttachmentData,
|
||||
logger,
|
||||
});
|
||||
|
||||
assert.isUndefined(actual.data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import { assert } from 'chai';
|
||||
import * as sinon from 'sinon';
|
||||
|
||||
import * as logger from '../../logging/log';
|
||||
import { IMAGE_GIF, IMAGE_PNG } from '../../types/MIME';
|
||||
import type { MessageAttributesType } from '../../model-types.d';
|
||||
import type { Avatar, Email, Phone } from '../../types/EmbeddedContact';
|
||||
|
@ -18,9 +19,6 @@ import { UUID } from '../../types/UUID';
|
|||
|
||||
describe('Contact', () => {
|
||||
const NUMBER = '+12025550099';
|
||||
const logger = {
|
||||
error: () => undefined,
|
||||
};
|
||||
|
||||
const writeNewAttachmentData = sinon
|
||||
.stub()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue