blob: 63e1d71980dcfc437acbc508ad23767e79b052cc [file] [log] [blame]
Devon Carew57b76a02016-07-19 20:00:02 -07001// 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 Carew57b76a02016-07-19 20:00:02 -07005import 'package:flutter_tools/src/base/config.dart';
Todd Volkert8bb27032017-01-06 16:51:44 -08006import 'package:flutter_tools/src/base/file_system.dart';
Ian Hickson686d8f82018-08-14 20:33:58 -07007
8import 'src/common.dart';
Devon Carew57b76a02016-07-19 20:00:02 -07009
10void main() {
11 Config config;
Ian Hickson3dec6a62018-08-17 13:17:23 -070012 Directory tempDir;
Devon Carew57b76a02016-07-19 20:00:02 -070013
14 setUp(() {
Ian Hickson3dec6a62018-08-17 13:17:23 -070015 tempDir = fs.systemTempDirectory.createTempSync('flutter_config_test.');
16 final File file = fs.file(fs.path.join(tempDir.path, '.settings'));
Alexandre Ardhuind927c932018-09-12 08:29:29 +020017 config = Config(file);
Devon Carew57b76a02016-07-19 20:00:02 -070018 });
19
Ian Hickson3dec6a62018-08-17 13:17:23 -070020 tearDown(() {
21 tryToDelete(tempDir);
22 });
23
Devon Carew57b76a02016-07-19 20:00:02 -070024 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 Carewc186d0d2017-07-18 18:47:20 -070032 test('containsKey', () async {
33 expect(config.containsKey('foo'), false);
34 config.setValue('foo', 'bar');
35 expect(config.containsKey('foo'), true);
36 });
37
Devon Carew57b76a02016-07-19 20:00:02 -070038 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}