config_test.dart 1.15 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 9 10 11 12 13
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main() {
  Config config;

  setUp(() {
14 15
    Directory tempDiretory = fs.systemTempDirectory.createTempSync('flutter_test');
    File file = fs.file(path.join(tempDiretory.path, '.settings'));
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
    config = new Config(file);
  });

  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'));
    });

    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')));
    });
  });
}