Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Unified Diff: pkg/analysis_server/test/index/store/separate_file_manager_test.dart

Issue 346273005: A FileManager implementation to keep each index file in a separate file system file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698