OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.src.plugin.plugin_config_test; |
| 6 |
| 7 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 8 import 'package:analyzer/src/plugin/plugin_configuration.dart'; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 |
| 11 main() { |
| 12 group('PluginConfig', () { |
| 13 group('parsing', () { |
| 14 test('plugin map', () { |
| 15 const optionsSrc = ''' |
| 16 analyzer: |
| 17 plugins: |
| 18 my_plugin1: ^0.1.0 #shorthand |
| 19 my_plugin2: |
| 20 version: ^0.2.0 |
| 21 my_plugin3: |
| 22 class_name: MyPlugin |
| 23 library_uri: myplugin/myplugin.dart |
| 24 path: '/u/disk/src/' |
| 25 '''; |
| 26 var config = parseConfig(optionsSrc); |
| 27 var plugins = pluginsSortedByName(config); |
| 28 expect(plugins, hasLength(3)); |
| 29 expect(plugins[0].name, equals('my_plugin1')); |
| 30 expect(plugins[0].version, equals('^0.1.0')); |
| 31 expect(plugins[1].name, equals('my_plugin2')); |
| 32 expect(plugins[1].version, equals('^0.2.0')); |
| 33 expect(plugins[2].name, equals('my_plugin3')); |
| 34 expect(plugins[2].version, isNull); |
| 35 expect(plugins[2].path, equals('/u/disk/src/')); |
| 36 expect(plugins[2].libraryUri, equals('myplugin/myplugin.dart')); |
| 37 expect(plugins[2].className, equals('MyPlugin')); |
| 38 }); |
| 39 }); |
| 40 }); |
| 41 } |
| 42 |
| 43 PluginConfig parseConfig(String optionsSrc) { |
| 44 var options = new AnalysisOptionsProvider().getOptionsFromString(optionsSrc); |
| 45 return new PluginConfig.fromOptions(options); |
| 46 } |
| 47 |
| 48 List<PluginInfo> pluginsSortedByName(PluginConfig config) => |
| 49 config.plugins.toList()..sort((p1, p2) => p1.name.compareTo(p2.name)); |
OLD | NEW |