forked from eatvio/eatvio_app
feat(image_compress_utility): adde test for corupted images
This commit is contained in:
@@ -426,5 +426,27 @@ void main() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('compressFile - does not crash on corrupted image', () async {
|
||||
final file = File('corrupted.jpg');
|
||||
|
||||
try {
|
||||
await file.writeAsBytes([
|
||||
0xFF, 0xD8, 0xFF, 0xE0,
|
||||
0x00, 0x10,
|
||||
0x4A, 0x46, 0x49, 0x46,
|
||||
0xFF, 0xDA,
|
||||
]);
|
||||
|
||||
final result = await ImageCompressUtility.compressFile(file);
|
||||
|
||||
expect(result, isA<File>());
|
||||
expect(result.path, file.path);
|
||||
} finally {
|
||||
if (await file.exists()) {
|
||||
await file.delete();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user