JJ_MKVMaker/test/live_sync_args_test.dart

45 lines
2.6 KiB
Dart
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

import 'package:flutter_test/flutter_test.dart';
import 'package:jj_mkvmaker/app/sync/sync_commands.dart';
import 'package:jj_mkvmaker/app/settings.dart';
/// 97: 실시간 동기화의 지우기는 쌍의 "지우기 포함" 으로만 (설정 옵션의 --delete · --del · /MIR · /PURGE 는 빼고)
void main() {
test('rsync: 설정 옵션의 지우기는 빼고, 쌍이 지우기 포함일 때만 --delete 하나', () {
final s = AppSettings()..copy.rsyncOptions = '-avPog --delete --del --delete-after';
final off = SyncCommands.rsyncArgs(LiveSyncPair('/a', '/b'), s, windows: false);
expect(off.where((o) => o.startsWith('--del')), isEmpty);
final on = SyncCommands.rsyncArgs(LiveSyncPair('/a', '/b', delete: true), s, windows: false);
expect(on.where((o) => o.startsWith('--del')), ['--delete']);
});
test('10/20: --delete-excluded 는 쌍이 지우기 포함일 때만 (지울지 묻는 목록과 같게)', () {
final s = AppSettings()..copy.rsyncOptions = '-av --exclude=*.tmp --delete-excluded';
final off = SyncCommands.rsyncArgs(LiveSyncPair('/a', '/b'), s, windows: false);
expect(off.where((o) => o.startsWith('--del')), isEmpty);
final on = SyncCommands.rsyncArgs(LiveSyncPair('/a', '/b', delete: true), s, windows: false);
expect(on.where((o) => o.startsWith('--del')), ['--delete', '--delete-excluded']);
expect(on, contains('--exclude=*.tmp'));
});
test('robocopy: /MIR 는 /E 로, /PURGE 는 쌍이 지우기 포함일 때만', () {
final s = AppSettings()..copy.robocopyOptions = '/MIR /PURGE /R:2';
final off = SyncCommands.robocopyArgs(LiveSyncPair(r'C:\a', r'D:\b'), s).map((o) => o.toUpperCase()).toList();
expect(off, isNot(contains('/MIR')));
expect(off, isNot(contains('/PURGE')));
expect(off, contains('/E'));
final on = SyncCommands.robocopyArgs(LiveSyncPair(r'C:\a', r'D:\b', delete: true), s).map((o) => o.toUpperCase()).toList();
expect(on.where((o) => o == '/PURGE'), hasLength(1));
});
test('107: 원본을 지우는 옵션 (--remove-source-files · /MOV · /MOVE) 도 실시간 동기화에서는 쓰지 않는다', () {
final s = AppSettings()
..copy.rsyncOptions = '-avPog --remove-source-files --remove-sent-files'
..copy.robocopyOptions = '/E /MOV /MOVE';
final r = SyncCommands.rsyncArgs(LiveSyncPair('/a', '/b', delete: true), s, windows: false);
expect(r.where((o) => o.startsWith('--remove')), isEmpty);
final w = SyncCommands.robocopyArgs(LiveSyncPair(r'C:', r'D:', delete: true), s).map((o) => o.toUpperCase()).toList();
expect(w, isNot(contains('/MOV')));
expect(w, isNot(contains('/MOVE')));
});
}