refs #5858 test: check vn_schedules
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
88a88640e5
commit
dddd482317
|
@ -1,6 +1,6 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
describe('zone toggleIsIncluded()', () => {
|
fdescribe('zone toggleIsIncluded()', () => {
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: 9},
|
accessToken: {userId: 9},
|
||||||
|
@ -20,10 +20,12 @@ describe('zone toggleIsIncluded()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
await validateSchedules('before', options);
|
||||||
|
|
||||||
let result = await models.Zone.toggleIsIncluded(1, 20, true, options);
|
let result = await models.Zone.toggleIsIncluded(1, 20, true, options);
|
||||||
|
|
||||||
expect(result.isIncluded).toBeTrue();
|
expect(result.isIncluded).toBeTrue();
|
||||||
|
await validateSchedules('after', options);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -37,10 +39,12 @@ describe('zone toggleIsIncluded()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
await validateSchedules('before', options);
|
||||||
|
|
||||||
let result = await models.Zone.toggleIsIncluded(1, 20, false, options);
|
let result = await models.Zone.toggleIsIncluded(1, 20, false, options);
|
||||||
|
|
||||||
expect(result.isIncluded).toBeFalse();
|
expect(result.isIncluded).toBeFalse();
|
||||||
|
await validateSchedules('after', options);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -54,13 +58,14 @@ describe('zone toggleIsIncluded()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
await validateSchedules('before', options);
|
||||||
await models.Zone.toggleIsIncluded(1, 20, false, options);
|
await models.Zone.toggleIsIncluded(1, 20, false, options);
|
||||||
|
|
||||||
let result = await models.Zone.toggleIsIncluded(1, 20, undefined, options);
|
const result = await models.Zone.toggleIsIncluded(1, 20, undefined, options);
|
||||||
|
|
||||||
expect(result).toEqual({count: 1});
|
expect(result).toEqual({count: 1});
|
||||||
|
|
||||||
|
await validateSchedules('after', options);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -68,3 +73,22 @@ describe('zone toggleIsIncluded()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function validateSchedules(step, options = null) {
|
||||||
|
const querySchedules = `SELECT count(*) count FROM util.vn_schedules;`;
|
||||||
|
|
||||||
|
switch (step) {
|
||||||
|
case 'before': {
|
||||||
|
const [{count}] = await models.Application.rawSql(querySchedules, null, options);
|
||||||
|
|
||||||
|
expect(count).toEqual(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'after': {
|
||||||
|
const [{count}] = await models.Application.rawSql(querySchedules, null, options);
|
||||||
|
|
||||||
|
expect(count).toEqual(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue