backups: add remotePath
the main motivation is that id can be used in REST API routes. previously, the id was a path and this had a "/" in it. This made /api/v1/backups/:backupId not work.
This commit is contained in:
@@ -22,7 +22,8 @@ describe('backup cleaner', function () {
|
||||
after(cleanup);
|
||||
|
||||
const backupTemplate = {
|
||||
id: 'someid',
|
||||
id: null,
|
||||
remotePath: 'somepath',
|
||||
encryptionVersion: 2,
|
||||
packageVersion: '1.0.0',
|
||||
type: backups.BACKUP_TYPE_BOX,
|
||||
@@ -125,7 +126,8 @@ describe('backup cleaner', function () {
|
||||
|
||||
describe('task', function () {
|
||||
const BACKUP_0_BOX = {
|
||||
id: 'backup-box-0',
|
||||
id: null,
|
||||
remotePath: 'backup-box-0',
|
||||
identifier: 'box',
|
||||
encryptionVersion: null,
|
||||
packageVersion: '1.0.0',
|
||||
@@ -137,7 +139,8 @@ describe('backup cleaner', function () {
|
||||
};
|
||||
|
||||
const BACKUP_0_APP_0 = { // backup of installed app
|
||||
id: 'backup-app-00',
|
||||
id: null,
|
||||
remotePath: 'backup-app-00',
|
||||
identifier: app.id,
|
||||
encryptionVersion: null,
|
||||
packageVersion: '1.0.0',
|
||||
@@ -149,7 +152,8 @@ describe('backup cleaner', function () {
|
||||
};
|
||||
|
||||
const BACKUP_0_APP_1 = { // this app is uninstalled
|
||||
id: 'backup-app-01',
|
||||
id: null,
|
||||
remotePath: 'backup-app-01',
|
||||
identifier: 'app1',
|
||||
encryptionVersion: null,
|
||||
packageVersion: '1.0.0',
|
||||
@@ -161,7 +165,8 @@ describe('backup cleaner', function () {
|
||||
};
|
||||
|
||||
const BACKUP_1_BOX = {
|
||||
id: 'backup-box-1',
|
||||
id: null,
|
||||
remotePath: 'backup-box-1',
|
||||
encryptionVersion: null,
|
||||
packageVersion: '1.0.0',
|
||||
type: backups.BACKUP_TYPE_BOX,
|
||||
@@ -173,7 +178,8 @@ describe('backup cleaner', function () {
|
||||
};
|
||||
|
||||
const BACKUP_1_APP_0 = {
|
||||
id: 'backup-app-10',
|
||||
id: null,
|
||||
remotePath: 'backup-app-10',
|
||||
encryptionVersion: null,
|
||||
packageVersion: '1.0.0',
|
||||
type: backups.BACKUP_TYPE_APP,
|
||||
@@ -185,7 +191,8 @@ describe('backup cleaner', function () {
|
||||
};
|
||||
|
||||
const BACKUP_1_APP_1 = {
|
||||
id: 'backup-app-11',
|
||||
id: null,
|
||||
remotePath: 'backup-app-11',
|
||||
encryptionVersion: null,
|
||||
packageVersion: '1.0.0',
|
||||
type: backups.BACKUP_TYPE_APP,
|
||||
@@ -228,14 +235,21 @@ describe('backup cleaner', function () {
|
||||
await cleanupBackups();
|
||||
});
|
||||
|
||||
it('succeeds with box backups, keeps latest', async function () {
|
||||
for (const backup of [[ BACKUP_0_BOX, BACKUP_0_APP_0, BACKUP_0_APP_1 ], [ BACKUP_1_BOX, BACKUP_1_APP_0, BACKUP_1_APP_1 ]]) {
|
||||
await delay(2000); // space out backups
|
||||
for (const b of backup) {
|
||||
await backups.add(b.id, b);
|
||||
}
|
||||
}
|
||||
it('add the backups', async function () {
|
||||
BACKUP_0_APP_0.id = await backups.add(BACKUP_0_APP_0);
|
||||
BACKUP_0_APP_1.id = await backups.add(BACKUP_0_APP_1);
|
||||
BACKUP_0_BOX.dependsOn = [ BACKUP_0_APP_0.id, BACKUP_0_APP_1.id ];
|
||||
BACKUP_0_BOX.id = await backups.add(BACKUP_0_BOX);
|
||||
|
||||
await delay(2000); // space out backups
|
||||
|
||||
BACKUP_1_APP_0.id = await backups.add(BACKUP_1_APP_0);
|
||||
BACKUP_1_APP_1.id = await backups.add(BACKUP_1_APP_1);
|
||||
BACKUP_1_BOX.dependsOn = [ BACKUP_1_APP_0.id, BACKUP_1_APP_1.id ];
|
||||
BACKUP_1_BOX.id = await backups.add(BACKUP_1_BOX);
|
||||
});
|
||||
|
||||
it('succeeds with box backups, keeps latest', async function () {
|
||||
await cleanupBackups();
|
||||
|
||||
const results = await backups.getByTypePaged(backups.BACKUP_TYPE_BOX, 1, 1000);
|
||||
@@ -261,7 +275,7 @@ describe('backup cleaner', function () {
|
||||
it('succeeds for app backups not referenced by a box backup', async function () {
|
||||
// add two dangling app backups not referenced by box backup. app1 is uninstalled. app0 is there
|
||||
for (const backup of [BACKUP_0_APP_0, BACKUP_0_APP_1]) {
|
||||
await backups.add(backup.id, backup);
|
||||
backup.id = await backups.add(backup);
|
||||
}
|
||||
|
||||
await delay(2000); // wait for expiration
|
||||
@@ -270,7 +284,7 @@ describe('backup cleaner', function () {
|
||||
|
||||
let result = await backups.getByTypePaged(backups.BACKUP_TYPE_APP, 1, 1000);
|
||||
expect(result.length).to.equal(3);
|
||||
result = result.sort((r1, r2) => r1.id.localeCompare(r2.id));
|
||||
result = result.sort((r1, r2) => r1.remotePath.localeCompare(r2.remotePath));
|
||||
expect(result[0].id).to.be(BACKUP_0_APP_0.id); // because app is installed, latest backup is preserved
|
||||
expect(result[1].id).to.be(BACKUP_1_APP_0.id); // referenced by box
|
||||
expect(result[2].id).to.be(BACKUP_1_APP_1.id); // referenced by box
|
||||
|
||||
Reference in New Issue
Block a user