Devon Carew | 57b76a0 | 2016-07-19 20:00:02 -0700 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Devon Carew | 57b76a0 | 2016-07-19 20:00:02 -0700 | [diff] [blame] | 5 | import 'package:flutter_tools/src/base/config.dart'; |
Todd Volkert | 8bb2703 | 2017-01-06 16:51:44 -0800 | [diff] [blame] | 6 | import 'package:flutter_tools/src/base/file_system.dart'; |
Ian Hickson | 686d8f8 | 2018-08-14 20:33:58 -0700 | [diff] [blame] | 7 | |
| 8 | import 'src/common.dart'; |
Devon Carew | 57b76a0 | 2016-07-19 20:00:02 -0700 | [diff] [blame] | 9 | |
| 10 | void main() { |
| 11 | Config config; |
Ian Hickson | 3dec6a6 | 2018-08-17 13:17:23 -0700 | [diff] [blame] | 12 | Directory tempDir; |
Devon Carew | 57b76a0 | 2016-07-19 20:00:02 -0700 | [diff] [blame] | 13 | |
| 14 | setUp(() { |
Ian Hickson | 3dec6a6 | 2018-08-17 13:17:23 -0700 | [diff] [blame] | 15 | tempDir = fs.systemTempDirectory.createTempSync('flutter_config_test.'); |
| 16 | final File file = fs.file(fs.path.join(tempDir.path, '.settings')); |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 17 | config = Config(file); |
Devon Carew | 57b76a0 | 2016-07-19 20:00:02 -0700 | [diff] [blame] | 18 | }); |
| 19 | |
Ian Hickson | 3dec6a6 | 2018-08-17 13:17:23 -0700 | [diff] [blame] | 20 | tearDown(() { |
| 21 | tryToDelete(tempDir); |
| 22 | }); |
| 23 | |
Devon Carew | 57b76a0 | 2016-07-19 20:00:02 -0700 | [diff] [blame] | 24 | group('config', () { |
| 25 | test('get set value', () async { |
| 26 | expect(config.getValue('foo'), null); |
| 27 | config.setValue('foo', 'bar'); |
| 28 | expect(config.getValue('foo'), 'bar'); |
| 29 | expect(config.keys, contains('foo')); |
| 30 | }); |
| 31 | |
Devon Carew | c186d0d | 2017-07-18 18:47:20 -0700 | [diff] [blame] | 32 | test('containsKey', () async { |
| 33 | expect(config.containsKey('foo'), false); |
| 34 | config.setValue('foo', 'bar'); |
| 35 | expect(config.containsKey('foo'), true); |
| 36 | }); |
| 37 | |
Devon Carew | 57b76a0 | 2016-07-19 20:00:02 -0700 | [diff] [blame] | 38 | test('removeValue', () async { |
| 39 | expect(config.getValue('foo'), null); |
| 40 | config.setValue('foo', 'bar'); |
| 41 | expect(config.getValue('foo'), 'bar'); |
| 42 | expect(config.keys, contains('foo')); |
| 43 | config.removeValue('foo'); |
| 44 | expect(config.getValue('foo'), null); |
| 45 | expect(config.keys, isNot(contains('foo'))); |
| 46 | }); |
| 47 | }); |
| 48 | } |