Files
cloudron-box/src/test/settings-test.js

96 lines
2.9 KiB
JavaScript
Raw Normal View History

/* global it:false */
/* global describe:false */
/* global before:false */
/* global after:false */
'use strict';
var async = require('async'),
2017-01-10 16:44:28 -08:00
database = require('../database.js'),
expect = require('expect.js'),
2017-09-27 10:25:36 -07:00
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');
2018-01-23 15:47:41 -08:00
function setup(done) {
2017-09-27 10:25:36 -07:00
nock.cleanAll();
2017-04-14 01:13:42 -07:00
async.series([
database.initialize,
function (callback) {
2017-09-27 10:25:36 -07:00
MockS3.config.basePath = path.join(os.tmpdir(), 's3-settings-test-buckets/');
s3._mockInject(MockS3);
2019-05-08 17:30:41 -07:00
callback();
}
], done);
}
function cleanup(done) {
2017-09-27 10:25:36 -07:00
s3._mockRestore();
rimraf.sync(MockS3.config.basePath);
async.series([
database._clear,
database.uninitialize
], done);
}
describe('Settings', function () {
describe('values', function () {
before(setup);
after(cleanup);
2021-08-19 13:24:38 -07:00
it('can get default timezone', async function () {
const tz = await settings.getTimeZone();
expect(tz.length).to.not.be(0);
});
2021-08-19 13:24:38 -07:00
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 name', async function () {
const name = await settings.getCloudronName();
expect(name).to.be('Cloudron');
});
it('can get default cloudron avatar', async function () {
const avatar = await settings.getCloudronAvatar();
expect(avatar).to.be.a(Buffer);
});
2021-08-19 13:24:38 -07:00
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');
2016-01-23 05:07:12 -08:00
});
it('can get default unstable apps setting', async function () {
const enabled = await settings.getUnstableAppsConfig();
expect(enabled).to.be(true);
});
it('can set unstable apps setting', async function () {
await settings.setUnstableAppsConfig(false);
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');
2015-10-26 00:44:54 -07:00
});
});
});