Unverified Commit 114ba8cc authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] add unit test for error 32 in cache deletion (#76714)

parent 109e0bb9
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment