2016-04-22 01:17:31 +00:00
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
|
|
|
import 'package:angel_configuration/angel_configuration.dart';
|
|
|
|
import 'package:test/test.dart';
|
2016-09-19 20:24:26 +00:00
|
|
|
import 'transformer.dart' as transformer;
|
2016-04-22 01:17:31 +00:00
|
|
|
|
2016-05-02 23:35:21 +00:00
|
|
|
main() async {
|
2016-04-22 01:17:31 +00:00
|
|
|
// Note: Set ANGEL_ENV to 'development'
|
2017-06-14 18:48:13 +00:00
|
|
|
var app = new Angel();
|
2017-08-16 00:29:13 +00:00
|
|
|
await app.configure(loadConfigurationFile(directoryPath: './test/config'));
|
2016-04-22 01:17:31 +00:00
|
|
|
|
2016-05-02 23:35:21 +00:00
|
|
|
test('can load based on ANGEL_ENV', () async {
|
2017-06-14 18:48:13 +00:00
|
|
|
expect(app.properties['hello'], equals('world'));
|
|
|
|
expect(app.properties['foo']['version'], equals('bar'));
|
2016-04-22 01:17:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('will load default.yaml if exists', () {
|
2017-06-14 18:48:13 +00:00
|
|
|
expect(app.properties["set_via"], equals("default"));
|
|
|
|
});
|
|
|
|
|
|
|
|
test('will load .env if exists', () {
|
|
|
|
expect(app.properties['artist'], 'Timberlake');
|
|
|
|
expect(app.properties['angel'], {'framework': 'cool'});
|
2016-04-22 01:17:31 +00:00
|
|
|
});
|
|
|
|
|
2017-06-14 18:48:13 +00:00
|
|
|
test('non-existent environment defaults to null', () {
|
|
|
|
expect(app.properties.keys, contains('must_be_null'));
|
|
|
|
expect(app.properties['must_be_null'], null);
|
|
|
|
});
|
2016-04-22 01:17:31 +00:00
|
|
|
|
2016-05-02 23:35:21 +00:00
|
|
|
test('can override ANGEL_ENV', () async {
|
2017-06-14 18:48:13 +00:00
|
|
|
await app.configure(loadConfigurationFile(
|
2016-04-22 01:17:31 +00:00
|
|
|
directoryPath: './test/config', overrideEnvironmentName: 'override'));
|
2017-06-14 18:48:13 +00:00
|
|
|
expect(app.properties['hello'], equals('goodbye'));
|
|
|
|
expect(app.properties['foo']['version'], equals('baz'));
|
2016-04-22 01:17:31 +00:00
|
|
|
});
|
2016-09-19 20:24:26 +00:00
|
|
|
|
2017-08-16 00:29:13 +00:00
|
|
|
test('merges configuration', () async {
|
|
|
|
await app.configure(loadConfigurationFile(
|
|
|
|
directoryPath: './test/config', overrideEnvironmentName: 'override'));
|
|
|
|
expect(app.properties['merge'], {'map': true, 'hello': 'goodbye'});
|
|
|
|
});
|
2017-06-14 18:48:13 +00:00
|
|
|
|
2016-09-19 20:24:26 +00:00
|
|
|
group("transformer", transformer.main);
|
|
|
|
}
|