backuptargets: add test that archives/backups are removed when target is deleted
This commit is contained in:
@@ -6,7 +6,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const backupTargets = require('../backuptargets.js'),
|
||||
const archives = require('../archives.js'),
|
||||
backups = require('../backups.js'),
|
||||
backupTargets = require('../backuptargets.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
common = require('./common.js'),
|
||||
constants = require('../constants.js'),
|
||||
@@ -14,7 +16,7 @@ const backupTargets = require('../backuptargets.js'),
|
||||
safe = require('safetydance');
|
||||
|
||||
describe('backups', function () {
|
||||
const { setup, cleanup, auditSource } = common;
|
||||
const { setup, cleanup, auditSource, getDefaultBackupTarget } = common;
|
||||
|
||||
before(async function () {
|
||||
await setup();
|
||||
@@ -30,8 +32,30 @@ describe('backups', function () {
|
||||
schedule: '00 00 23 * * *'
|
||||
};
|
||||
|
||||
const appBackup = {
|
||||
id: null,
|
||||
remotePath: 'backup-box',
|
||||
encryptionVersion: 2,
|
||||
packageVersion: '1.0.0',
|
||||
type: backups.BACKUP_TYPE_APP,
|
||||
state: backups.BACKUP_STATE_NORMAL,
|
||||
identifier: 'box',
|
||||
dependsOn: [ 'dep1' ],
|
||||
manifest: null,
|
||||
preserveSecs: 0,
|
||||
label: '',
|
||||
appConfig: { loc: 'loc1' },
|
||||
targetId: null
|
||||
};
|
||||
|
||||
let defaultBackupTarget = null;
|
||||
|
||||
before(async function () {
|
||||
appBackup.targetId = (await getDefaultBackupTarget()).id;
|
||||
appBackup.id = await backups.add(appBackup);
|
||||
await archives.add(appBackup.id, {}, auditSource);
|
||||
});
|
||||
|
||||
it('can add another target', async function () {
|
||||
const id = await backupTargets.add(backupTarget, auditSource);
|
||||
expect(id).to.be.ok();
|
||||
@@ -107,5 +131,7 @@ describe('backups', function () {
|
||||
|
||||
it('can delete non-primary backup target', async function () {
|
||||
await backupTargets.del(defaultBackupTarget, auditSource);
|
||||
expect(await backups.list(1, 10)).to.eql([]);
|
||||
expect(await archives.list(1, 10)).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user