rename backupTargets to backupSites

This commit is contained in:
Girish Ramakrishnan
2025-09-12 09:48:37 +02:00
parent f8015c156e
commit c5b7264f1a
38 changed files with 751 additions and 751 deletions
+21 -21
View File
@@ -9,7 +9,7 @@
const archives = require('../archives.js'),
backupCleaner = require('../backupcleaner.js'),
backups = require('../backups.js'),
backupTargets = require('../backuptargets.js'),
backupSites = require('../backupsites.js'),
common = require('./common.js'),
expect = require('expect.js'),
moment = require('moment'),
@@ -17,7 +17,7 @@ const archives = require('../archives.js'),
timers = require('timers/promises');
describe('backup cleaner', function () {
const { setup, cleanup, app, getDefaultBackupTarget, auditSource } = common;
const { setup, cleanup, app, getDefaultBackupSite, auditSource } = common;
before(setup);
after(cleanup);
@@ -126,7 +126,7 @@ describe('backup cleaner', function () {
});
describe('task', function () {
let target;
let site;
const BACKUP_0_BOX = {
id: null,
@@ -140,7 +140,7 @@ describe('backup cleaner', function () {
manifest: null,
preserveSecs: 0,
appConfig: null,
targetId: null
siteId: null
};
const BACKUP_0_APP_0 = { // backup of installed app
@@ -155,7 +155,7 @@ describe('backup cleaner', function () {
manifest: null,
preserveSecs: 0,
appConfig: null,
targetId: null
siteId: null
};
const BACKUP_0_APP_1 = { // this app is uninstalled
@@ -170,7 +170,7 @@ describe('backup cleaner', function () {
manifest: null,
preserveSecs: 0,
appConfig: null,
targetId: null
siteId: null
};
const BACKUP_1_BOX = {
@@ -185,7 +185,7 @@ describe('backup cleaner', function () {
manifest: null,
preserveSecs: 0,
appConfig: null,
targetId: null
siteId: null
};
const BACKUP_1_APP_0 = {
@@ -200,7 +200,7 @@ describe('backup cleaner', function () {
manifest: null,
preserveSecs: 0,
appConfig: null,
targetId: null
siteId: null
};
const BACKUP_1_APP_1 = {
@@ -215,7 +215,7 @@ describe('backup cleaner', function () {
manifest: null,
preserveSecs: 0,
appConfig: null,
targetId: null
siteId: null
};
const BACKUP_2_APP_2 = { // this is archived and left alone
@@ -230,21 +230,21 @@ describe('backup cleaner', function () {
manifest: null,
preserveSecs: 0,
appConfig: null,
targetId: null
siteId: null
};
before(async function () {
target = await getDefaultBackupTarget();
await backupTargets.setConfig(target, {
site = await getDefaultBackupSite();
await backupSites.setConfig(site, {
provider: 'filesystem',
backupDir: '/tmp/someplace',
}, auditSource);
await backupTargets.setRetention(target, { keepWithinSecs: 1 }, auditSource);
await backupTargets.setSchedule(target, '00 00 23 * * *', auditSource);
await backupSites.setRetention(site, { keepWithinSecs: 1 }, auditSource);
await backupSites.setSchedule(site, '00 00 23 * * *', auditSource);
});
async function cleanupBackups(target) {
const taskId = await backupTargets.startCleanupTask(target, auditSource);
async function cleanupBackups(site) {
const taskId = await backupSites.startCleanupTask(site, auditSource);
console.log('started task', taskId);
@@ -261,12 +261,12 @@ describe('backup cleaner', function () {
}
it('succeeds without backups', async function () {
await cleanupBackups(target);
await cleanupBackups(site);
});
it('add the backups', async function () {
for (const b of [BACKUP_0_APP_0, BACKUP_0_APP_1, BACKUP_0_BOX, BACKUP_1_APP_0, BACKUP_1_APP_1, BACKUP_1_BOX, BACKUP_2_APP_2]) {
b.targetId = target.id;
b.siteId = site.id;
}
BACKUP_0_APP_0.id = await backups.add(BACKUP_0_APP_0);
@@ -286,7 +286,7 @@ describe('backup cleaner', function () {
});
it('succeeds with box backups, keeps latest', async function () {
await cleanupBackups(target);
await cleanupBackups(site);
const results = await backups.getByTypePaged(backups.BACKUP_TYPE_BOX, 1, 1000);
expect(results.length).to.equal(1);
@@ -298,7 +298,7 @@ describe('backup cleaner', function () {
});
it('does not remove expired backups if only one left', async function () {
await cleanupBackups(target);
await cleanupBackups(site);
const results = await backups.getByTypePaged(backups.BACKUP_TYPE_BOX, 1, 1000);
expect(results[0].id).to.equal(BACKUP_1_BOX.id);
@@ -316,7 +316,7 @@ describe('backup cleaner', function () {
await timers.setTimeout(2000); // wait for expiration
await cleanupBackups(target);
await cleanupBackups(site);
let result = await backups.getByTypePaged(backups.BACKUP_TYPE_APP, 1, 1000);
expect(result.length).to.equal(4);