1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/options.test.js

34 lines
872 B
JavaScript
Raw Normal View History

2016-12-01 00:42:14 +01:00
'use strict';
const test = require('ava');
delete process.env.DATABASE_URL;
test('should require DATABASE_URI', t => {
2016-12-04 14:09:37 +01:00
const { createOptions } = require('./options');
2016-12-01 00:42:14 +01:00
t.throws(() => {
2016-12-04 14:09:37 +01:00
createOptions({});
2016-12-01 00:42:14 +01:00
});
});
2016-12-03 13:45:22 +01:00
test('should set default databaseUrl for develpment', t => {
2016-12-04 14:09:37 +01:00
process.env.NODE_ENV = 'development';
2016-12-01 00:42:14 +01:00
const { createOptions } = require('./options');
2016-12-04 14:09:37 +01:00
2016-12-01 00:42:14 +01:00
const options = createOptions({});
2016-12-03 13:45:22 +01:00
t.true(options.databaseUrl === 'postgres://unleash_user:passord@localhost:5432/unleash');
2016-12-01 00:42:14 +01:00
});
test('should not override provided options', t => {
2016-12-04 14:09:37 +01:00
process.env.DATABASE_URL = 'test';
2016-12-01 00:42:14 +01:00
process.env.NODE_ENV = 'production';
const { createOptions } = require('./options');
2016-12-04 14:09:37 +01:00
const options = createOptions({ databaseUrl: 'test', port: 1111 });
2016-12-01 00:42:14 +01:00
2016-12-03 13:45:22 +01:00
t.true(options.databaseUrl === 'test');
2016-12-01 00:42:14 +01:00
t.true(options.port === 1111);
2016-12-04 14:09:37 +01:00
});