backup: add archive flag
This commit is contained in:
@@ -32,7 +32,8 @@ describe('backup cleaner', function () {
|
||||
dependsOn: [ 'dep1' ],
|
||||
manifest: null,
|
||||
format: 'tgz',
|
||||
preserveSecs: 0
|
||||
preserveSecs: 0,
|
||||
archive: false
|
||||
};
|
||||
|
||||
describe('retention', function () {
|
||||
@@ -43,25 +44,25 @@ describe('backup cleaner', function () {
|
||||
});
|
||||
|
||||
it('does not keep latest', function () {
|
||||
let backup = { creationTime: moment().subtract(5, 's').toDate(), state: backups.BACKUP_STATE_NORMAL };
|
||||
const backup = { creationTime: moment().subtract(5, 's').toDate(), state: backups.BACKUP_STATE_NORMAL };
|
||||
backupCleaner._applyBackupRetention([backup], { keepWithinSecs: 1, keepLatest: false }, []);
|
||||
expect(backup.keepReason).to.be(undefined);
|
||||
});
|
||||
|
||||
it('always keeps forever policy', function () {
|
||||
let backup = { creationTime: new Date() };
|
||||
const backup = { creationTime: new Date() };
|
||||
backupCleaner._applyBackupRetention([backup], { keepWithinSecs: -1, keepLatest: true }, []);
|
||||
expect(backup.keepReason).to.be('keepWithinSecs');
|
||||
});
|
||||
|
||||
it('preserveSecs takes precedence', function () {
|
||||
let backup = { creationTime: new Date(), preserveSecs: 3000 };
|
||||
const backup = { creationTime: new Date(), preserveSecs: 3000 };
|
||||
backupCleaner._applyBackupRetention([backup], { keepWithinSecs: 1, keepLatest: true }, []);
|
||||
expect(backup.keepReason).to.be('preserveSecs');
|
||||
});
|
||||
|
||||
it('1 daily', function () {
|
||||
let b = [
|
||||
const b = [
|
||||
{ id: '0', state: backups.BACKUP_STATE_NORMAL, creationTime: moment().toDate() },
|
||||
{ id: '1', state: backups.BACKUP_STATE_NORMAL, creationTime: moment().subtract(1, 'h').toDate() },
|
||||
{ id: '2', state: backups.BACKUP_STATE_NORMAL, creationTime: moment().subtract(3, 'h').toDate() },
|
||||
@@ -78,7 +79,7 @@ describe('backup cleaner', function () {
|
||||
|
||||
// if you are debugging this test, it's because of some timezone issue with all the hour substraction!
|
||||
it('2 daily, 1 weekly', function () {
|
||||
let b = [
|
||||
const b = [
|
||||
{ id: '0', state: backups.BACKUP_STATE_NORMAL, creationTime: moment().toDate() },
|
||||
{ id: '1', state: backups.BACKUP_STATE_NORMAL, creationTime: moment().subtract(1, 'h').toDate() },
|
||||
{ id: '2', state: backups.BACKUP_STATE_NORMAL, creationTime: moment().subtract(3, 'h').toDate() },
|
||||
@@ -98,7 +99,7 @@ describe('backup cleaner', function () {
|
||||
});
|
||||
|
||||
it('2 daily, 3 monthly, 1 yearly', function () {
|
||||
let b = [
|
||||
const b = [
|
||||
{ id: '0', state: backups.BACKUP_STATE_CREATING, creationTime: moment().toDate() },
|
||||
{ id: '1', state: backups.BACKUP_STATE_ERROR, creationTime: moment().toDate() },
|
||||
{ id: '2', state: backups.BACKUP_STATE_NORMAL, creationTime: moment().toDate() },
|
||||
@@ -122,6 +123,12 @@ describe('backup cleaner', function () {
|
||||
expect(b[8].keepReason).to.be('keepMonthly');
|
||||
expect(b[9].keepReason).to.be(undefined);
|
||||
});
|
||||
|
||||
it('keeps archive', function () {
|
||||
const backup = Object.assign({}, backupTemplate, { archive: true });
|
||||
backupCleaner._applyBackupRetention([backup], { keepWithinSecs: 0, keepLatest: false }, []);
|
||||
expect(backup.keepReason).to.be('archive');
|
||||
});
|
||||
});
|
||||
|
||||
describe('task', function () {
|
||||
|
||||
Reference in New Issue
Block a user