Upgrade hive database version to 14
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -90,28 +90,27 @@ class FileUtils {
|
||||
return emailContent;
|
||||
}
|
||||
|
||||
Future<bool> isFileExisted({
|
||||
required String nameFile,
|
||||
String? folderPath,
|
||||
String? extensionFile
|
||||
}) async {
|
||||
final internalStorageDirPath = await _getInternalStorageDirPath(
|
||||
nameFile: nameFile,
|
||||
folderPath: folderPath,
|
||||
extensionFile: extensionFile
|
||||
);
|
||||
|
||||
return File(internalStorageDirPath).exists();
|
||||
Future<Directory?> getFolder(String folderName) async {
|
||||
try {
|
||||
String folderPath = (await getApplicationDocumentsDirectory()).absolute.path;
|
||||
folderPath = '$folderPath/$folderName';
|
||||
log('FileUtils::getFolder(): $folderPath');
|
||||
return Directory(folderPath);
|
||||
} catch (e) {
|
||||
logError('FileUtils::getFolder():EXCEPTION: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeFolder(String folderName) async {
|
||||
try {
|
||||
String folderPath = (await getApplicationDocumentsDirectory()).absolute.path;
|
||||
folderPath = '$folderPath/$folderName';
|
||||
log('FileUtils::removeFolder():folderPath: $folderPath');
|
||||
final dir = Directory(folderPath);
|
||||
final dir = await getFolder(folderName);
|
||||
if (dir == null) return;
|
||||
|
||||
if (await dir.exists()) {
|
||||
await dir.delete(recursive: true);
|
||||
await dir.create(); // Re-create folder
|
||||
log('FileUtils::removeFolder: Remove ${dir.path} success');
|
||||
}
|
||||
} catch (e) {
|
||||
logError('FileUtils::removeFolder():EXCEPTION: $e');
|
||||
|
||||
@@ -14,7 +14,7 @@ void main() {
|
||||
final htmlValidate = sanitizeAutolinkFilter.process('See https://linagora.com at Hanoi');
|
||||
expect(
|
||||
htmlValidate,
|
||||
equals('See <a href="https://linagora.com" target="_blank" rel="noreferrer">linagora.com</a> at Hanoi')
|
||||
equals('See <a href="https://linagora.com" target="_blank" rel="noreferrer" style="white-space: nowrap; word-break: keep-all;">linagora.com</a> at Hanoi')
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -25,7 +25,7 @@ void main() {
|
||||
final htmlValidate = sanitizeAutolinkFilter.process('See http://linagora.com at Hanoi');
|
||||
expect(
|
||||
htmlValidate,
|
||||
equals('See <a href="http://linagora.com" target="_blank" rel="noreferrer">linagora.com</a> at Hanoi')
|
||||
equals('See <a href="http://linagora.com" target="_blank" rel="noreferrer" style="white-space: nowrap; word-break: keep-all;">linagora.com</a> at Hanoi')
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -36,7 +36,7 @@ void main() {
|
||||
final htmlValidate = sanitizeAutolinkFilter.process('See www.linagora.com at Hanoi');
|
||||
expect(
|
||||
htmlValidate,
|
||||
equals('See <a href="https://www.linagora.com" target="_blank" rel="noreferrer">linagora.com</a> at Hanoi')
|
||||
equals('See <a href="https://www.linagora.com" target="_blank" rel="noreferrer" style="white-space: nowrap; word-break: keep-all;">linagora.com</a> at Hanoi')
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -47,7 +47,7 @@ void main() {
|
||||
final htmlValidate = sanitizeAutolinkFilter.process('See tdvu@linagora.com at Hanoi');
|
||||
expect(
|
||||
htmlValidate,
|
||||
equals('See <a href="mailto:tdvu@linagora.com">tdvu@linagora.com</a> at Hanoi')
|
||||
equals('See <a href="mailto:tdvu@linagora.com" style="white-space: nowrap; word-break: keep-all;">tdvu@linagora.com</a> at Hanoi')
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -11,13 +11,15 @@ void main() {
|
||||
const fileContent = 'Hello, World!';
|
||||
|
||||
group('fileUtils test', () {
|
||||
final fileUtils = FileUtils();
|
||||
|
||||
setUp(() async {
|
||||
PathProviderPlatform.instance = FakePathProviderPlatform();
|
||||
});
|
||||
|
||||
test('Store private HTLM String to File', () async {
|
||||
|
||||
final file = await FileUtils().saveToFile(nameFile: fileName, content: fileContent);
|
||||
final file = await fileUtils.saveToFile(nameFile: fileName, content: fileContent);
|
||||
|
||||
expect(await file.exists(), equals(true));
|
||||
|
||||
@@ -29,9 +31,9 @@ void main() {
|
||||
test('Get HTML String from File Private', () async {
|
||||
|
||||
/// Create a temporary file that will be deleted after `getFromFile` is done
|
||||
final file = await FileUtils().saveToFile(nameFile: fileName, content: fileContent);
|
||||
final file = await fileUtils.saveToFile(nameFile: fileName, content: fileContent);
|
||||
|
||||
final htmlString = await FileUtils().getContentFromFile(nameFile: fileName);
|
||||
final htmlString = await fileUtils.getContentFromFile(nameFile: fileName);
|
||||
|
||||
expect(htmlString.isNotEmpty, equals(true));
|
||||
|
||||
@@ -47,10 +49,10 @@ void main() {
|
||||
'and Platform is mobile',
|
||||
() async {
|
||||
// arrange
|
||||
final file = await FileUtils().saveToFile(nameFile: fileName, content: fileContent);
|
||||
final file = await fileUtils.saveToFile(nameFile: fileName, content: fileContent);
|
||||
|
||||
// act
|
||||
await FileUtils().deleteCompressedFileOnMobile(file.path, pathContains: fileName);
|
||||
await fileUtils.deleteCompressedFileOnMobile(file.path, pathContains: fileName);
|
||||
|
||||
// assert
|
||||
expect(await file.exists(), equals(false));
|
||||
@@ -64,11 +66,11 @@ void main() {
|
||||
() async {
|
||||
// arrange
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
|
||||
final file = await FileUtils().saveToFile(nameFile: fileName, content: fileContent);
|
||||
final file = await fileUtils.saveToFile(nameFile: fileName, content: fileContent);
|
||||
expect(await file.exists(), equals(true));
|
||||
|
||||
// act
|
||||
await FileUtils().deleteCompressedFileOnMobile(file.path, pathContains: fileName);
|
||||
await fileUtils.deleteCompressedFileOnMobile(file.path, pathContains: fileName);
|
||||
|
||||
// assert
|
||||
expect(await file.exists(), equals(true));
|
||||
|
||||
@@ -373,6 +373,14 @@ void main() {
|
||||
expect(StringConvert.isTextTable(table), isTrue);
|
||||
});
|
||||
|
||||
test('should return true for separator-only Markdown', () {
|
||||
const text = """
|
||||
|----------|----------|
|
||||
|----------|----------|
|
||||
""";
|
||||
expect(StringConvert.isTextTable(text), isTrue);
|
||||
});
|
||||
|
||||
// ---------------------------
|
||||
// Test cases cho ASCII art tables
|
||||
// ---------------------------
|
||||
@@ -437,14 +445,6 @@ void main() {
|
||||
expect(StringConvert.isTextTable(' \n \n '), isFalse);
|
||||
});
|
||||
|
||||
test('should return true for separator-only Markdown', () {
|
||||
const text = """
|
||||
|----------|----------|
|
||||
|----------|----------|
|
||||
""";
|
||||
expect(StringConvert.isTextTable(text), isTrue);
|
||||
});
|
||||
|
||||
test('should return false for single-line Markdown', () {
|
||||
const text = '| Header 1 | Header 2 |';
|
||||
expect(StringConvert.isTextTable(text), isFalse);
|
||||
|
||||
Reference in New Issue
Block a user