| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library test.engine.src.index.store.separate_file_mananer; | |
| 6 | |
| 7 import 'dart:io'; | |
| 8 | |
| 9 import 'package:analysis_testing/reflective_tests.dart'; | |
| 10 import 'package:analyzer/src/index/store/separate_file_manager.dart'; | |
| 11 import 'package:path/path.dart'; | |
| 12 import 'package:unittest/unittest.dart'; | |
| 13 | |
| 14 | |
| 15 main() { | |
| 16 groupSep = ' | '; | |
| 17 group('SeparateFileManager', () { | |
| 18 runReflectiveTests(_SeparateFileManagerTest); | |
| 19 }); | |
| 20 } | |
| 21 | |
| 22 | |
| 23 @ReflectiveTestCase() | |
| 24 class _SeparateFileManagerTest { | |
| 25 Directory tempDir; | |
| 26 SeparateFileManager fileManager; | |
| 27 | |
| 28 void setUp() { | |
| 29 tempDir = Directory.systemTemp.createTempSync('AnalysisServer_index'); | |
| 30 fileManager = new SeparateFileManager(tempDir); | |
| 31 } | |
| 32 | |
| 33 void tearDown() { | |
| 34 tempDir.delete(recursive: true); | |
| 35 } | |
| 36 | |
| 37 test_clear() { | |
| 38 String name = "42.index"; | |
| 39 // create the file | |
| 40 return fileManager.write(name, <int>[1, 2, 3, 4]).then((_) { | |
| 41 // check that the file exists | |
| 42 expect(_existsSync(name), isTrue); | |
| 43 // clear | |
| 44 fileManager.clear(); | |
| 45 expect(_existsSync(name), isFalse); | |
| 46 }); | |
| 47 } | |
| 48 | |
| 49 test_delete_doesNotExist() { | |
| 50 String name = "42.index"; | |
| 51 fileManager.delete(name); | |
| 52 } | |
| 53 | |
| 54 test_outputInput() { | |
| 55 String name = "42.index"; | |
| 56 // create the file | |
| 57 return fileManager.write(name, <int>[1, 2, 3, 4]).then((_) { | |
| 58 // check that that the file exists | |
| 59 expect(_existsSync(name), isTrue); | |
| 60 // read the file | |
| 61 return fileManager.read(name).then((bytes) { | |
| 62 expect(bytes, <int>[1, 2, 3, 4]); | |
| 63 // delete | |
| 64 fileManager.delete(name); | |
| 65 // the file does not exist anymore | |
| 66 return fileManager.read(name).then((bytes) { | |
| 67 expect(bytes, isNull); | |
| 68 }); | |
| 69 }); | |
| 70 }); | |
| 71 } | |
| 72 | |
| 73 bool _existsSync(String name) { | |
| 74 return new File(join(tempDir.path, name)).existsSync(); | |
| 75 } | |
| 76 } | |
| OLD | NEW |