backups: split listing and targets
This commit is contained in:
+20
-19
@@ -6,7 +6,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const backups = require('../backups.js'),
|
||||
const backupListing = require('../backuplisting.js'),
|
||||
backups = require('../backups.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
@@ -20,8 +21,8 @@ describe('backups', function () {
|
||||
remotePath: 'backup-box',
|
||||
encryptionVersion: 2,
|
||||
packageVersion: '1.0.0',
|
||||
type: backups.BACKUP_TYPE_BOX,
|
||||
state: backups.BACKUP_STATE_NORMAL,
|
||||
type: backupListing.BACKUP_TYPE_BOX,
|
||||
state: backupListing.BACKUP_STATE_NORMAL,
|
||||
identifier: 'box',
|
||||
dependsOn: [ 'dep1' ],
|
||||
manifest: null,
|
||||
@@ -36,8 +37,8 @@ describe('backups', function () {
|
||||
remotePath: 'app_appid_123',
|
||||
encryptionVersion: null,
|
||||
packageVersion: '1.0.0',
|
||||
type: backups.BACKUP_TYPE_APP,
|
||||
state: backups.BACKUP_STATE_CREATING,
|
||||
type: backupListing.BACKUP_TYPE_APP,
|
||||
state: backupListing.BACKUP_STATE_CREATING,
|
||||
identifier: 'appid',
|
||||
dependsOn: [ ],
|
||||
manifest: { foo: 'bar' },
|
||||
@@ -57,65 +58,65 @@ describe('backups', function () {
|
||||
|
||||
describe('crud', function () {
|
||||
it('add succeeds', async function () {
|
||||
boxBackup.id = await backups.add(boxBackup);
|
||||
boxBackup.id = await backupListing.add(boxBackup);
|
||||
});
|
||||
|
||||
it('fails with duplicate path', async function () {
|
||||
const [error] = await safe(backups.add(boxBackup));
|
||||
const [error] = await safe(backupListing.add(boxBackup));
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
});
|
||||
|
||||
it('get succeeds', async function () {
|
||||
const result = await backups.get(boxBackup.id);
|
||||
const result = await backupListing.get(boxBackup.id);
|
||||
delete result.creationTime;
|
||||
expect(result).to.eql(boxBackup);
|
||||
});
|
||||
|
||||
it('get of unknown id fails', async function () {
|
||||
const result = await backups.get('somerandom');
|
||||
const result = await backupListing.get('somerandom');
|
||||
expect(result).to.be(null);
|
||||
});
|
||||
|
||||
it('getByTypePaged succeeds', async function () {
|
||||
const results = await backups.getByTypePaged(backups.BACKUP_TYPE_BOX, 1, 5);
|
||||
const results = await backupListing.getByTypePaged(backupListing.BACKUP_TYPE_BOX, 1, 5);
|
||||
expect(results.length).to.be(1);
|
||||
delete results[0].creationTime;
|
||||
expect(results[0]).to.eql(boxBackup);
|
||||
});
|
||||
|
||||
it('update succeeds', async function () {
|
||||
await backups.update(boxBackup.id, { label: 'DuMonde', preserveSecs: 30 });
|
||||
const result = await backups.get(boxBackup.id);
|
||||
await backupListing.update(boxBackup.id, { label: 'DuMonde', preserveSecs: 30 });
|
||||
const result = await backupListing.get(boxBackup.id);
|
||||
expect(result.label).to.eql('DuMonde');
|
||||
expect(result.preserveSecs).to.eql(30);
|
||||
});
|
||||
|
||||
it('delete succeeds', async function () {
|
||||
await backups.del(boxBackup.id);
|
||||
const result = await backups.get(boxBackup.id);
|
||||
await backupListing.del(boxBackup.id);
|
||||
const result = await backupListing.get(boxBackup.id);
|
||||
expect(result).to.be(null);
|
||||
});
|
||||
|
||||
it('add app backup succeeds', async function () {
|
||||
appBackup.id = await backups.add(appBackup);
|
||||
appBackup.id = await backupListing.add(appBackup);
|
||||
});
|
||||
|
||||
it('get app backup succeeds', async function () {
|
||||
const result = await backups.get(appBackup.id);
|
||||
const result = await backupListing.get(appBackup.id);
|
||||
delete result.creationTime;
|
||||
expect(result).to.eql(appBackup);
|
||||
});
|
||||
|
||||
it('getByIdentifierAndStatePaged succeeds', async function () {
|
||||
const results = await backups.getByIdentifierAndStatePaged(appBackup.identifier, backups.BACKUP_STATE_CREATING, 1, 5);
|
||||
const results = await backupListing.getByIdentifierAndStatePaged(appBackup.identifier, backupListing.BACKUP_STATE_CREATING, 1, 5);
|
||||
expect(results.length).to.be(1);
|
||||
delete results[0].creationTime;
|
||||
expect(results[0]).to.eql(appBackup);
|
||||
});
|
||||
|
||||
it('delete app backup succeeds', async function () {
|
||||
await backups.del(appBackup.id);
|
||||
const result = await backups.get(appBackup.id);
|
||||
await backupListing.del(appBackup.id);
|
||||
const result = await backupListing.get(appBackup.id);
|
||||
expect(result).to.be(null);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user