rename backups to backuptargets
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const backups = require('../../backups.js'),
|
||||
const backupTargets = require('../../backuptargets.js'),
|
||||
common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
superagent = require('@cloudron/superagent');
|
||||
@@ -111,7 +111,7 @@ describe('Backups API', function () {
|
||||
|
||||
describe('backup_config', function () {
|
||||
// keep in sync with defaults in settings.js
|
||||
let defaultConfig = {
|
||||
const defaultConfig = {
|
||||
provider: 'filesystem',
|
||||
backupFolder: '/var/backups',
|
||||
format: 'tgz',
|
||||
@@ -127,7 +127,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config without provider', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
delete tmp.provider;
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -139,7 +139,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid provider', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.provider = 'invalid provider';
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -151,7 +151,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config without format', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
delete tmp.format;
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -163,7 +163,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid format', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.format = 'invalid format';
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -175,7 +175,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid password', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.password = 1234;
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -187,7 +187,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid syncConcurrency', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.limits = { syncConcurrency: 'not a number' };
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -199,7 +199,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid syncConcurrency', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.limits = { syncConcurrency: 0 };
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -211,7 +211,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid acceptSelfSignedCerts', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.acceptSelfSignedCerts = 'not a boolean';
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -223,7 +223,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('can set backup_config', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.format = 'rsync';
|
||||
tmp.backupFolder = BACKUP_FOLDER;
|
||||
tmp.limits = { copyConcurrency: 34 };
|
||||
@@ -247,7 +247,7 @@ describe('Backups API', function () {
|
||||
|
||||
describe('create', function () {
|
||||
before(async function () {
|
||||
await backups.setStorage({
|
||||
await backupTargets.setStorage({
|
||||
provider: 'filesystem',
|
||||
backupFolder: '/tmp/backups',
|
||||
format: 'tgz',
|
||||
@@ -282,7 +282,7 @@ describe('Backups API', function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/backups`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.backups.length).to.be(1);
|
||||
expect(response.body.backupTargets.length).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -293,7 +293,7 @@ describe('Backups API', function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/backups`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.backups.length).to.be(1);
|
||||
expect(response.body.backupTargets.length).to.be(1);
|
||||
someBackup = response.body.backups[0];
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user