make settings-test follow the new pattern
This commit is contained in:
@@ -5,91 +5,59 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var async = require('async'),
|
||||
database = require('../database.js'),
|
||||
const common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
MockS3 = require('mock-aws-s3'),
|
||||
nock = require('nock'),
|
||||
os = require('os'),
|
||||
path = require('path'),
|
||||
rimraf = require('rimraf'),
|
||||
s3 = require('../storage/s3.js'),
|
||||
settings = require('../settings.js');
|
||||
|
||||
function setup(done) {
|
||||
nock.cleanAll();
|
||||
|
||||
async.series([
|
||||
database.initialize,
|
||||
function (callback) {
|
||||
MockS3.config.basePath = path.join(os.tmpdir(), 's3-settings-test-buckets/');
|
||||
|
||||
s3._mockInject(MockS3);
|
||||
|
||||
callback();
|
||||
}
|
||||
], done);
|
||||
}
|
||||
|
||||
function cleanup(done) {
|
||||
s3._mockRestore();
|
||||
rimraf.sync(MockS3.config.basePath);
|
||||
|
||||
async.series([
|
||||
database._clear,
|
||||
database.uninitialize
|
||||
], done);
|
||||
}
|
||||
|
||||
describe('Settings', function () {
|
||||
describe('values', function () {
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
const { setup, cleanup } = common;
|
||||
|
||||
it('can get default timezone', async function () {
|
||||
const tz = await settings.getTimeZone();
|
||||
expect(tz.length).to.not.be(0);
|
||||
});
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
|
||||
it('can get default autoupdate_pattern', async function () {
|
||||
const pattern = await settings.getAutoupdatePattern();
|
||||
expect(pattern).to.be('00 00 1,3,5,23 * * *');
|
||||
});
|
||||
it('can get default timezone', async function () {
|
||||
const tz = await settings.getTimeZone();
|
||||
expect(tz.length).to.not.be(0);
|
||||
});
|
||||
|
||||
it ('can get default cloudron name', async function () {
|
||||
const name = await settings.getCloudronName();
|
||||
expect(name).to.be('Cloudron');
|
||||
});
|
||||
it('can get default autoupdate_pattern', async function () {
|
||||
const pattern = await settings.getAutoupdatePattern();
|
||||
expect(pattern).to.be('00 00 1,3,5,23 * * *');
|
||||
});
|
||||
|
||||
it('can get default cloudron avatar', async function () {
|
||||
const avatar = await settings.getCloudronAvatar();
|
||||
expect(avatar).to.be.a(Buffer);
|
||||
});
|
||||
it ('can get default cloudron name', async function () {
|
||||
const name = await settings.getCloudronName();
|
||||
expect(name).to.be('Cloudron');
|
||||
});
|
||||
|
||||
it('can get backup config', async function () {
|
||||
const backupConfig = await settings.getBackupConfig();
|
||||
expect(backupConfig.provider).to.be('filesystem');
|
||||
expect(backupConfig.backupFolder).to.be('/var/backups');
|
||||
});
|
||||
it('can get default cloudron avatar', async function () {
|
||||
const avatar = await settings.getCloudronAvatar();
|
||||
expect(avatar).to.be.a(Buffer);
|
||||
});
|
||||
|
||||
it('can get default unstable apps setting', async function () {
|
||||
const enabled = await settings.getUnstableAppsConfig();
|
||||
expect(enabled).to.be(true);
|
||||
});
|
||||
it('can get backup config', async function () {
|
||||
const backupConfig = await settings.getBackupConfig();
|
||||
expect(backupConfig.provider).to.be('filesystem');
|
||||
expect(backupConfig.backupFolder).to.be('/var/backups');
|
||||
});
|
||||
|
||||
it('can set unstable apps setting', async function () {
|
||||
await settings.setUnstableAppsConfig(false);
|
||||
it('can get default unstable apps setting', async function () {
|
||||
const enabled = await settings.getUnstableAppsConfig();
|
||||
expect(enabled).to.be(true);
|
||||
});
|
||||
|
||||
const enabled = await settings.getUnstableAppsConfig();
|
||||
expect(enabled).to.be(false);
|
||||
});
|
||||
it('can set unstable apps setting', async function () {
|
||||
await settings.setUnstableAppsConfig(false);
|
||||
|
||||
it('can get all values', async function () {
|
||||
const allSettings = await settings.list();
|
||||
expect(allSettings[settings.TIME_ZONE_KEY]).to.be.a('string');
|
||||
expect(allSettings[settings.AUTOUPDATE_PATTERN_KEY]).to.be.a('string');
|
||||
expect(allSettings[settings.CLOUDRON_NAME_KEY]).to.be.a('string');
|
||||
expect(allSettings[settings.UNSTABLE_APPS_KEY]).to.be.a('boolean');
|
||||
});
|
||||
const enabled = await settings.getUnstableAppsConfig();
|
||||
expect(enabled).to.be(false);
|
||||
});
|
||||
|
||||
it('can get all values', async function () {
|
||||
const allSettings = await settings.list();
|
||||
expect(allSettings[settings.TIME_ZONE_KEY]).to.be.a('string');
|
||||
expect(allSettings[settings.AUTOUPDATE_PATTERN_KEY]).to.be.a('string');
|
||||
expect(allSettings[settings.CLOUDRON_NAME_KEY]).to.be.a('string');
|
||||
expect(allSettings[settings.UNSTABLE_APPS_KEY]).to.be.a('boolean');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user