Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check for copied directories #1967

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions pkgs/io/test/copy_path_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,36 @@ import 'package:test_descriptor/test_descriptor.dart' as d;
void main() {
test('should copy a directory (async)', () async {
await _create();
await copyPath(p.join(d.sandbox, 'parent'), p.join(d.sandbox, 'copy'));
await copyPath(p.join(d.sandbox, _parentDir), p.join(d.sandbox, _copyDir));
await _validate();
});

test('should copy a directory (sync)', () async {
await _create();
copyPathSync(p.join(d.sandbox, 'parent'), p.join(d.sandbox, 'copy'));
copyPathSync(p.join(d.sandbox, _parentDir), p.join(d.sandbox, _copyDir));
await _validate();
});

test('should catch an infinite operation', () async {
await _create();
expect(
copyPath(
p.join(d.sandbox, 'parent'),
p.join(d.sandbox, 'parent', 'child'),
p.join(d.sandbox, _parentDir),
p.join(d.sandbox, _parentDir, 'child'),
),
throwsArgumentError,
);
});
}

d.DirectoryDescriptor _struct() => d.dir('parent', [
const _parentDir = 'parent';
const _copyDir = 'copy';

d.DirectoryDescriptor _struct(String dirName) => d.dir(dirName, [
d.dir('child', [
d.file('foo.txt'),
]),
]);

Future<void> _create() => _struct().create();
Future<void> _validate() => _struct().validate();
Future<void> _create() => _struct(_parentDir).create();
Future<void> _validate() => _struct(_copyDir).validate();
Loading