Add configurable with functions

Add more tests for call functions and fixed
This commit is contained in:
2021-03-24 14:10:25 +07:00
parent a51d5fe00b
commit 33b6355bcf
7 changed files with 67 additions and 40 deletions

View File

@@ -1,3 +1,5 @@
import 'package:configurable/configurable.dart' show getConfigOrNull;
import 'package:configurable/dotenv_configuration_provider.dart';
import 'package:configurable/system_config.dart';
import 'package:test/test.dart';
@@ -10,5 +12,27 @@ void main() {
expect(value, equals(result));
expect(value, equals(SystemConfig.getOrNull(key)));
});
test('get system config by key with dotenv provider', () {
var key = 'app.name';
var value = 'CUBETIQ Solution';
// set dotenv provider
SystemConfig.setProvider(DotenvConfigurationProvider());
var result = SystemConfig.getOrNull(key);
expect(value, equals(result));
expect(value, equals(SystemConfig.getOrNull(key)));
});
test('get config by key with function', () {
var key = 'app.name';
var value = 'CUBETIQ Solution';
var result = getConfigOrNull(key, defaultValue: value);
expect(value, equals(result));
expect(value, equals(getConfigOrNull(key)));
});
}