mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-14 15:33:17 +08:00

This reverts commit 303192d9d575b26a77a00f7a62212f310ec1e329. This reverts commit cd9d128b47ed523036f7ae1232ec7adcf04ed8a9. GitJournal is used by non-English speakers (a lot in China and Russia) and while we don't support those languages completely, we do support them a little bit. I don't want to loose this functionality. It would be better for us to fix the bug in intl.
62 lines
1.7 KiB
Dart
62 lines
1.7 KiB
Dart
import 'dart:io';
|
|
import 'dart:math';
|
|
|
|
import 'package:gitjournal/core/flattened_notes_folder.dart';
|
|
import 'package:gitjournal/core/notes_folder_fs.dart';
|
|
import 'package:gitjournal/core/note.dart';
|
|
import 'package:path/path.dart' as p;
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
group('Flattened Notes Folder Large Test', () {
|
|
Directory tempDir;
|
|
NotesFolderFS rootFolder;
|
|
|
|
setUp(() async {
|
|
tempDir = await Directory.systemTemp.createTemp('__flat_folder_test__');
|
|
// print("TempDir: ${tempDir.path}");
|
|
|
|
var random = Random();
|
|
for (var i = 0; i < 300; i++) {
|
|
// print("Building Note $i");
|
|
await _writeRandomNote(random, tempDir.path);
|
|
}
|
|
|
|
rootFolder = NotesFolderFS(null, tempDir.path);
|
|
await rootFolder.loadRecursively();
|
|
});
|
|
|
|
tearDown(() async {
|
|
// print("Cleaning Up TempDir: ${tempDir.path}");
|
|
tempDir.deleteSync(recursive: true);
|
|
});
|
|
|
|
test('Should load all the notes flattened', () async {
|
|
var f = FlattenedNotesFolder(rootFolder);
|
|
expect(f.notes.length, 300);
|
|
|
|
var tempDir = await Directory.systemTemp.createTemp('_test_');
|
|
await _writeRandomNote(Random(), tempDir.path);
|
|
|
|
rootFolder.reset(tempDir.path);
|
|
await rootFolder.loadRecursively();
|
|
expect(f.notes.length, 1);
|
|
});
|
|
});
|
|
}
|
|
|
|
Future<void> _writeRandomNote(Random random, String dirPath) async {
|
|
String path;
|
|
while (true) {
|
|
path = p.join(dirPath, "${random.nextInt(10000)}.md");
|
|
if (!File(path).existsSync()) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
var note = Note(NotesFolderFS(null, dirPath), path);
|
|
note.modified = DateTime(2014, 1, 1 + (random.nextInt(2000)));
|
|
note.body = "p1";
|
|
await note.save();
|
|
}
|