fix: backTest
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
ec81b12239
commit
e0e015c268
|
@ -33,7 +33,7 @@ module.exports = Self => {
|
|||
|
||||
const zip = new JSZip();
|
||||
let totalSize = 0;
|
||||
const zipConfig = await models.ZipConfig.findOne();
|
||||
const zipConfig = await models.ZipConfig.findOne(null, myOptions);
|
||||
for (let id of ids) {
|
||||
if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large');
|
||||
const invoiceOutPdf = await models.InvoiceOut.download(ctx, id, myOptions);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
describe('InvoiceOut downloadZip()', () => {
|
||||
const userId = 9;
|
||||
|
@ -12,20 +13,41 @@ describe('InvoiceOut downloadZip()', () => {
|
|||
};
|
||||
|
||||
it('should return part of link to dowloand the zip', async() => {
|
||||
const result = await models.InvoiceOut.downloadZip(ctx, invoiceIds);
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.InvoiceOut.downloadZip(ctx, invoiceIds, options);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return an error if the size of the files is too large', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const zipConfig = {
|
||||
maxSize: 0
|
||||
};
|
||||
await models.ZipConfig.create(zipConfig, options);
|
||||
|
||||
await models.ZipConfig.create(zipConfig);
|
||||
await models.InvoiceOut.downloadZip(ctx, invoiceIds, options);
|
||||
|
||||
const result = await models.InvoiceOut.downloadZip(ctx, invoiceIds);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(result).toBe(false);
|
||||
expect(error).toEqual(new UserError(`Files are too large`));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue