mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] add unit test for error 32 in cache deletion (#76714)
This commit is contained in:
parent
109e0bb9f5
commit
114ba8cc3e
@ -438,6 +438,38 @@ void main() {
|
||||
expect(fileSystem.file('a/b/c/d'), isNot(exists));
|
||||
expect(logger.errorText, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('ArtifactUpdater will tool exit if deleting the existing artifacts fails with 32 on windows', () async {
|
||||
const int kSharingViolation = 32;
|
||||
final FileExceptionHandler handler = FileExceptionHandler();
|
||||
final FakeOperatingSystemUtils operatingSystemUtils = FakeOperatingSystemUtils();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test(opHandle: handler.opHandle);
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final ArtifactUpdater artifactUpdater = ArtifactUpdater(
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
operatingSystemUtils: operatingSystemUtils,
|
||||
platform: FakePlatform(operatingSystem: 'windows'),
|
||||
httpClient: FakeHttpClient.any(),
|
||||
tempStorage: fileSystem.currentDirectory.childDirectory('temp')
|
||||
..createSync(),
|
||||
);
|
||||
|
||||
final Directory errorDirectory = fileSystem.currentDirectory
|
||||
.childDirectory('out')
|
||||
.childDirectory('test')
|
||||
..createSync(recursive: true);
|
||||
handler.addError(errorDirectory, FileSystemOp.delete, const FileSystemException('', '', OSError('', kSharingViolation)));
|
||||
|
||||
await expectLater(() async => await artifactUpdater.downloadZippedTarball(
|
||||
'test message',
|
||||
Uri.parse('http://test.zip'),
|
||||
fileSystem.currentDirectory.childDirectory('out'),
|
||||
), throwsToolExit(
|
||||
message: 'Failed to delete /out/test because the local file/directory is in use by another process'
|
||||
));
|
||||
expect(fileSystem.file('out/test'), isNot(exists));
|
||||
});
|
||||
}
|
||||
|
||||
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
|
||||
|
Loading…
Reference in New Issue
Block a user