[flutter_tools] add error handling wrapping for File.createSync (#73890)

This commit is contained in:
Jonah Williams
2021-01-13 14:25:37 -08:00
committed by GitHub
parent 1eb0bb52e1
commit abb48f495b
2 changed files with 19 additions and 0 deletions

View File

@@ -76,6 +76,8 @@ void setupWriteMocks({
when(mockFile.openSync(
mode: anyNamed('mode'),
)).thenThrow(FileSystemException('', '', OSError('', errorCode)));
when(mockFile.createSync(recursive: anyNamed('recursive')))
.thenThrow(FileSystemException('', '', OSError('', errorCode)));
}
void setupReadMocks({
@@ -230,6 +232,8 @@ void main() {
throwsToolExit(message: expectedMessage));
expect(() => file.openSync(),
throwsToolExit(message: expectedMessage));
expect(() => file.createSync(),
throwsToolExit(message: expectedMessage));
});
testWithoutContext('when writing to a full device', () async {
@@ -293,6 +297,8 @@ void main() {
throwsToolExit(message: expectedMessage));
expect(() => file.openSync(),
throwsToolExit(message: expectedMessage));
expect(() => file.createSync(),
throwsToolExit(message: expectedMessage));
});
testWithoutContext('when creating a temporary dir on a full device', () async {
@@ -390,6 +396,8 @@ void main() {
throwsToolExit(message: expectedMessage));
expect(() => file.openSync(),
throwsToolExit(message: expectedMessage));
expect(() => file.createSync(),
throwsToolExit(message: expectedMessage));
});
testWithoutContext('when access is denied for directories', () async {