config_test.dart 1.33 KB
Newer Older
1 2 3 4 5
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_tools/src/base/config.dart';
6
import 'package:flutter_tools/src/base/file_system.dart';
7 8

import 'src/common.dart';
9 10 11

void main() {
  Config config;
12
  Directory tempDir;
13 14

  setUp(() {
15 16
    tempDir = fs.systemTempDirectory.createTempSync('flutter_config_test.');
    final File file = fs.file(fs.path.join(tempDir.path, '.settings'));
17
    config = Config(file);
18 19
  });

20 21 22 23
  tearDown(() {
    tryToDelete(tempDir);
  });

24 25 26 27 28 29 30 31
  group('config', () {
    test('get set value', () async {
      expect(config.getValue('foo'), null);
      config.setValue('foo', 'bar');
      expect(config.getValue('foo'), 'bar');
      expect(config.keys, contains('foo'));
    });

32 33 34 35 36 37
    test('containsKey', () async {
      expect(config.containsKey('foo'), false);
      config.setValue('foo', 'bar');
      expect(config.containsKey('foo'), true);
    });

38 39 40 41 42 43 44 45 46 47 48
    test('removeValue', () async {
      expect(config.getValue('foo'), null);
      config.setValue('foo', 'bar');
      expect(config.getValue('foo'), 'bar');
      expect(config.keys, contains('foo'));
      config.removeValue('foo');
      expect(config.getValue('foo'), null);
      expect(config.keys, isNot(contains('foo')));
    });
  });
}