archives: use separate table
Cleaner to separate things from the backups table. * icon, appConfig, appStoreIcon etc are only valid for archives * older version cloudron does not have appConfig in backups table (so it cannot be an archive entry)
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const backups = require('../../backups.js'),
|
||||
const archives = require('../../archives.js'),
|
||||
backups = require('../../backups.js'),
|
||||
common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
superagent = require('superagent');
|
||||
@@ -13,7 +14,7 @@ const backups = require('../../backups.js'),
|
||||
describe('Archives API', function () {
|
||||
const { setup, cleanup, serverUrl, owner } = common;
|
||||
|
||||
const nonArchiveBackup = {
|
||||
const appBackup = {
|
||||
id: null,
|
||||
remotePath: 'app_appid_123',
|
||||
encryptionVersion: null,
|
||||
@@ -26,16 +27,15 @@ describe('Archives API', function () {
|
||||
format: 'tgz',
|
||||
preserveSecs: 0,
|
||||
label: '',
|
||||
archive: false
|
||||
};
|
||||
|
||||
const archiveBackup = Object.assign({}, nonArchiveBackup, {archive: true, remotePath: 'app_appid_234'});
|
||||
const appConfig = { loc: 'loc1' };
|
||||
let archiveId;
|
||||
|
||||
before(async function () {
|
||||
await setup();
|
||||
nonArchiveBackup.id = await backups.add(nonArchiveBackup);
|
||||
archiveBackup.id = await backups.add(archiveBackup);
|
||||
await backups.update(archiveBackup.id, { archive: true });
|
||||
appBackup.id = await backups.add(appBackup);
|
||||
archiveId = await archives.add(appBackup.id, { appConfig });
|
||||
});
|
||||
after(cleanup);
|
||||
|
||||
@@ -44,14 +44,14 @@ describe('Archives API', function () {
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.archives.length).to.be(1);
|
||||
expect(response.body.archives[0].id).to.be(archiveBackup.id);
|
||||
expect(response.body.archives[0].id).to.be(archiveId);
|
||||
});
|
||||
|
||||
it('get valid archive', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/archives/${archiveBackup.id}`)
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/archives/${archiveId}`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.remotePath).to.be('app_appid_234');
|
||||
expect(response.body.appConfig).to.eql(appConfig);
|
||||
});
|
||||
|
||||
it('cannot get invalid archive', async function () {
|
||||
@@ -62,14 +62,14 @@ describe('Archives API', function () {
|
||||
});
|
||||
|
||||
it('cannot del invalid archive', async function () {
|
||||
const response = await superagent.del(`${serverUrl}/api/v1/archives/${nonArchiveBackup.id}`)
|
||||
const response = await superagent.del(`${serverUrl}/api/v1/archives/random`)
|
||||
.query({ access_token: owner.token })
|
||||
.ok(() => true);
|
||||
expect(response.statusCode).to.equal(404);
|
||||
});
|
||||
|
||||
it('del valid archive', async function () {
|
||||
const response = await superagent.del(`${serverUrl}/api/v1/archives/${archiveBackup.id}`)
|
||||
const response = await superagent.del(`${serverUrl}/api/v1/archives/${archiveId}`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.statusCode).to.equal(204);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user