Skip to content

Commit 444ca0f

Browse files
committed
Update remove_file_test.dart
1 parent d8bdd11 commit 444ca0f

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

pkgs/io_file/test/remove_file_test.dart

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void tests(FileUtils utils, FileSystem fs) {
7979
expect(
8080
() => fileSystem.removeFile(path),
8181
throwsA(
82-
isA<PathAccessException>().having(
82+
isA<IOFileException>().having(
8383
(e) => e.errorCode,
8484
'errorCode',
8585
fileSystem is WindowsFileSystem
@@ -99,10 +99,29 @@ void tests(FileUtils utils, FileSystem fs) {
9999
utils.createDirectory(dirPath);
100100
io.Link(linkPath).createSync(dirPath);
101101

102-
fileSystem.removeFile(linkPath);
103-
104-
expect(utils.exists(dirPath), isTrue, reason: '$dirPath does not exist');
105-
expect(utils.exists(linkPath), isFalse, reason: '$linkPath exists');
102+
if (fs is WindowsFileSystem) {
103+
expect(
104+
() => fileSystem.removeFile(linkPath),
105+
throwsA(
106+
isA<PathAccessException>().having(
107+
(e) => e.errorCode,
108+
'errorCode',
109+
win32.ERROR_ACCESS_DENIED,
110+
),
111+
),
112+
);
113+
expect(utils.exists(dirPath), isTrue, reason: '$dirPath does not exist');
114+
expect(
115+
utils.exists(linkPath),
116+
isTrue,
117+
reason: '$linkPath does not exist',
118+
);
119+
} else {
120+
fileSystem.removeFile(linkPath);
121+
122+
expect(utils.exists(dirPath), isTrue, reason: '$dirPath does not exist');
123+
expect(utils.exists(linkPath), isFalse, reason: '$linkPath exists');
124+
}
106125
});
107126

108127
test('link to file', () {

0 commit comments

Comments
 (0)