| 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.services.src.index.store.separate_file_mananer; | |
| 6 | |
| 7 import 'dart:io'; | |
| 8 | |
| 9 import 'package:analysis_services/src/index/store/separate_file_manager.dart'; | |
| 10 import 'package:analysis_testing/reflective_tests.dart'; | |
| 11 import 'package:path/path.dart'; | |
| 12 import 'package:unittest/unittest.dart'; | |
| 13 | |
| 14 | |
| 15 main() { | |
| 16 groupSep = ' | '; | |
| 17 runReflectiveTests(_SeparateFileManagerTest); | |
| 18 } | |
| 19 | |
| 20 | |
| 21 @ReflectiveTestCase() | |
| 22 class _SeparateFileManagerTest { | |
| 23 Directory tempDir; | |
| 24 SeparateFileManager fileManager; | |
| 25 | |
| 26 void setUp() { | |
| 27 tempDir = Directory.systemTemp.createTempSync('AnalysisServer_index'); | |
| 28 fileManager = new SeparateFileManager(tempDir); | |
| 29 } | |
| 30 | |
| 31 void tearDown() { | |
| 32 tempDir.delete(recursive: true); | |
| 33 } | |
| 34 | |
| 35 test_clear() { | |
| 36 String name = "42.index"; | |
| 37 // create the file | |
| 38 return fileManager.write(name, <int>[1, 2, 3, 4]).then((_) { | |
| 39 // check that the file exists | |
| 40 expect(_existsSync(name), isTrue); | |
| 41 // clear | |
| 42 fileManager.clear(); | |
| 43 expect(_existsSync(name), isFalse); | |
| 44 }); | |
| 45 } | |
| 46 | |
| 47 test_delete_doesNotExist() { | |
| 48 String name = "42.index"; | |
| 49 fileManager.delete(name); | |
| 50 } | |
| 51 | |
| 52 test_outputInput() { | |
| 53 String name = "42.index"; | |
| 54 // create the file | |
| 55 return fileManager.write(name, <int>[1, 2, 3, 4]).then((_) { | |
| 56 // check that that the file exists | |
| 57 expect(_existsSync(name), isTrue); | |
| 58 // read the file | |
| 59 return fileManager.read(name).then((bytes) { | |
| 60 expect(bytes, <int>[1, 2, 3, 4]); | |
| 61 // delete | |
| 62 fileManager.delete(name); | |
| 63 // the file does not exist anymore | |
| 64 return fileManager.read(name).then((bytes) { | |
| 65 expect(bytes, isNull); | |
| 66 }); | |
| 67 }); | |
| 68 }); | |
| 69 } | |
| 70 | |
| 71 bool _existsSync(String name) { | |
| 72 return new File(join(tempDir.path, name)).existsSync(); | |
| 73 } | |
| 74 } | |
| OLD | NEW |