Skip to content

Commit

Permalink
make test more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkolos committed Jun 26, 2024
1 parent 76fd84b commit 3d9e87b
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -867,14 +867,40 @@ void main() {
});

testWithoutContext('ErrorHandlingFileSystem.systemTempDirectory wraps systemTempDirectory of delegate', () {
final MemoryFileSystem delegate = MemoryFileSystem.test();
final FileExceptionHandler exceptionHandler = FileExceptionHandler();

final MemoryFileSystem delegate = MemoryFileSystem.test(
style: FileSystemStyle.windows,
opHandle: exceptionHandler.opHandle,
);

final FileSystem fs = ErrorHandlingFileSystem(
delegate: delegate,
platform: const LocalPlatform(),
platform: FakePlatform(operatingSystem: 'windows'),
);

expect(fs.systemTempDirectory, isA<ErrorHandlingDirectory>());
expect(fs.systemTempDirectory.path, delegate.systemTempDirectory.path);

final File tempFile = delegate.systemTempDirectory.childFile('hello')
..createSync(recursive: true);

exceptionHandler.addError(
tempFile,
FileSystemOp.write,
FileSystemException(
'Oh no!',
tempFile.path,
const OSError('Access denied ):', 5),
),
);

expect(
() => fs.file(tempFile.path).writeAsStringSync('world'),
throwsToolExit(message: r'''
Flutter failed to write to a file at "C:\.tmp_rand0\hello". The flutter tool cannot access the file or directory.
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.'''),
);
});

group('ProcessManager on windows throws tool exit', () {
Expand Down

0 comments on commit 3d9e87b

Please sign in to comment.