Skip to content

Commit 30de295

Browse files
authored
Fix check for copied directories (#1967)
The current tests have no useful validation and pass even if the methods under test are empty because they check that a directory is the same as itself. Add a directory name argument when creating the test descriptor directory and use the parent and copy directory name for `_create` and `_validate` respectively. Add constants for the directory names.
1 parent c94c563 commit 30de295

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pkgs/io/test/copy_path_test.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,36 @@ import 'package:test_descriptor/test_descriptor.dart' as d;
1313
void main() {
1414
test('should copy a directory (async)', () async {
1515
await _create();
16-
await copyPath(p.join(d.sandbox, 'parent'), p.join(d.sandbox, 'copy'));
16+
await copyPath(p.join(d.sandbox, _parentDir), p.join(d.sandbox, _copyDir));
1717
await _validate();
1818
});
1919

2020
test('should copy a directory (sync)', () async {
2121
await _create();
22-
copyPathSync(p.join(d.sandbox, 'parent'), p.join(d.sandbox, 'copy'));
22+
copyPathSync(p.join(d.sandbox, _parentDir), p.join(d.sandbox, _copyDir));
2323
await _validate();
2424
});
2525

2626
test('should catch an infinite operation', () async {
2727
await _create();
2828
expect(
2929
copyPath(
30-
p.join(d.sandbox, 'parent'),
31-
p.join(d.sandbox, 'parent', 'child'),
30+
p.join(d.sandbox, _parentDir),
31+
p.join(d.sandbox, _parentDir, 'child'),
3232
),
3333
throwsArgumentError,
3434
);
3535
});
3636
}
3737

38-
d.DirectoryDescriptor _struct() => d.dir('parent', [
38+
const _parentDir = 'parent';
39+
const _copyDir = 'copy';
40+
41+
d.DirectoryDescriptor _struct(String dirName) => d.dir(dirName, [
3942
d.dir('child', [
4043
d.file('foo.txt'),
4144
]),
4245
]);
4346

44-
Future<void> _create() => _struct().create();
45-
Future<void> _validate() => _struct().validate();
47+
Future<void> _create() => _struct(_parentDir).create();
48+
Future<void> _validate() => _struct(_copyDir).validate();

0 commit comments

Comments
 (0)