| Index: pkg/analysis_server/test/index/store/separate_file_manager_test.dart
|
| diff --git a/pkg/analysis_server/test/index/store/separate_file_manager_test.dart b/pkg/analysis_server/test/index/store/separate_file_manager_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6c3c0e2845f5ba427cd57c079ffb6e0442c76516
|
| --- /dev/null
|
| +++ b/pkg/analysis_server/test/index/store/separate_file_manager_test.dart
|
| @@ -0,0 +1,77 @@
|
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +library test.index.store.separate_file_mananer;
|
| +
|
| +import 'dart:io';
|
| +
|
| +import 'package:analysis_server/src/index/store/separate_file_manager.dart';
|
| +import 'package:path/path.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| +import '../../reflective_tests.dart';
|
| +
|
| +
|
| +main() {
|
| + groupSep = ' | ';
|
| + group('SeparateFileManager', () {
|
| + runReflectiveTests(_SeparateFileManagerTest);
|
| + });
|
| +}
|
| +
|
| +
|
| +@ReflectiveTestCase()
|
| +class _SeparateFileManagerTest {
|
| + SeparateFileManager fileManager;
|
| + Directory tempDir;
|
| +
|
| + void setUp() {
|
| + tempDir = Directory.systemTemp.createTempSync('AnalysisServer_index');
|
| + fileManager = new SeparateFileManager(tempDir);
|
| + }
|
| +
|
| + void tearDown() {
|
| + tempDir.delete(recursive: true);
|
| + }
|
| +
|
| + test_clear() {
|
| + String name = "42.index";
|
| + // create the file
|
| + return fileManager.write(name, <int>[1, 2, 3, 4]).then((_) {
|
| + // check that the file exists
|
| + expect(_existsSync(name), isTrue);
|
| + // clear
|
| + fileManager.clear();
|
| + expect(_existsSync(name), isFalse);
|
| + });
|
| + }
|
| +
|
| + test_delete_doesNotExist() {
|
| + String name = "42.index";
|
| + fileManager.delete(name);
|
| + }
|
| +
|
| + test_outputInput() {
|
| + String name = "42.index";
|
| + // create the file
|
| + return fileManager.write(name, <int>[1, 2, 3, 4]).then((_) {
|
| + // check that that the file exists
|
| + expect(_existsSync(name), isTrue);
|
| + // read the file
|
| + return fileManager.read(name).then((bytes) {
|
| + expect(bytes, <int>[1, 2, 3, 4]);
|
| + // delete
|
| + fileManager.delete(name);
|
| + // the file does not exist anymore
|
| + return fileManager.read(name).then((bytes) {
|
| + expect(bytes, isNull);
|
| + });
|
| + });
|
| + });
|
| + }
|
| +
|
| + bool _existsSync(String name) {
|
| + return new File(join(tempDir.path, name)).existsSync();
|
| + }
|
| +}
|
|
|