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();
|
const zip = new JSZip();
|
||||||
let totalSize = 0;
|
let totalSize = 0;
|
||||||
const zipConfig = await models.ZipConfig.findOne();
|
const zipConfig = await models.ZipConfig.findOne(null, myOptions);
|
||||||
for (let id of ids) {
|
for (let id of ids) {
|
||||||
if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large');
|
if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large');
|
||||||
const invoiceOutPdf = await models.InvoiceOut.download(ctx, id, myOptions);
|
const invoiceOutPdf = await models.InvoiceOut.download(ctx, id, myOptions);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
describe('InvoiceOut downloadZip()', () => {
|
describe('InvoiceOut downloadZip()', () => {
|
||||||
const userId = 9;
|
const userId = 9;
|
||||||
|
@ -12,20 +13,41 @@ describe('InvoiceOut downloadZip()', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should return part of link to dowloand the zip', async() => {
|
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({});
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
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() => {
|
it('should return an error if the size of the files is too large', async() => {
|
||||||
const zipConfig = {
|
const tx = await models.Order.beginTransaction({});
|
||||||
maxSize: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
await models.ZipConfig.create(zipConfig);
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const zipConfig = {
|
||||||
|
maxSize: 0
|
||||||
|
};
|
||||||
|
await models.ZipConfig.create(zipConfig, options);
|
||||||
|
|
||||||
const result = await models.InvoiceOut.downloadZip(ctx, invoiceIds);
|
await models.InvoiceOut.downloadZip(ctx, invoiceIds, options);
|
||||||
|
|
||||||
expect(result).toBe(false);
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(new UserError(`Files are too large`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue