|
4 | 4 | // |
5 | 5 | // Created by Thomas Evensen on 18/12/2025. |
6 | 6 | // |
7 | | - |
| 7 | +// swiftlint:disable all |
| 8 | +// xcodebuild -scheme RsyncUI -project RsyncUI.xcodeproj -destination 'platform=macOS' -only-testing:RsyncUITests test |
8 | 9 | import Testing |
| 10 | +import Foundation |
| 11 | +import RsyncArguments |
9 | 12 | @testableimport RsyncUI |
10 | 13 |
|
11 | 14 | structRsyncUITests{ |
12 | 15 |
|
| 16 | +@MainActor |
| 17 | +@Suite("Arguments Generation Tests",.serialized) |
| 18 | +structArgumentsSynchronizeTests{ |
| 19 | +func makeConfig( |
| 20 | + task:String="synchronize", |
| 21 | + local:String="/Users/test/Documents/", |
| 22 | + remote:String="/backup/Documents/", |
| 23 | + username:String="", |
| 24 | + server:String="" |
| 25 | +)->SynchronizeConfiguration{ |
| 26 | +varcfg=SynchronizeConfiguration() |
| 27 | + cfg.task= task |
| 28 | + cfg.localCatalog= local |
| 29 | + cfg.offsiteCatalog= remote |
| 30 | + cfg.offsiteUsername= username |
| 31 | + cfg.offsiteServer= server |
| 32 | + cfg.halted=0 |
| 33 | +return cfg |
| 34 | +} |
| 35 | + |
| 36 | +@Test("Synchronize returns dry-run args") |
| 37 | +func synchronizeDryRunArgs()async{ |
| 38 | +SharedReference.shared.rsyncversion3=true |
| 39 | + |
| 40 | +letcfg=makeConfig() |
| 41 | +letgenerator=ArgumentsSynchronize(config: cfg) |
| 42 | +letargs= generator.argumentsSynchronize(dryRun:true, forDisplay:false) |
| 43 | + |
| 44 | + #expect(args!=nil) |
| 45 | + // Accept either common dry-run flags |
| 46 | + #expect(args!.contains("--dry-run") || args!.contains("-n")) |
| 47 | +} |
| 48 | +/* |
| 49 | + @Test("Snapshot task produces arguments") |
| 50 | + func snapshotArgs() async { |
| 51 | + SharedReference.shared.rsyncversion3 = true |
| 52 | + |
| 53 | + var cfg = makeConfig(task: SharedReference.shared.snapshot, |
| 54 | + username: "testuser", |
| 55 | + server: "localhost") |
| 56 | + let generator = ArgumentsSynchronize(config: cfg) |
| 57 | + let args = generator.argumentsSynchronize(dryRun: false, forDisplay: false) |
| 58 | + |
| 59 | + #expect(args != nil) |
| 60 | + } |
| 61 | +*/ |
| 62 | +@Test("Syncremote task produces arguments") |
| 63 | +func syncremoteArgs()async{ |
| 64 | +SharedReference.shared.rsyncversion3=true |
| 65 | + |
| 66 | +letcfg=makeConfig(task:SharedReference.shared.syncremote, |
| 67 | + username:"testuser", |
| 68 | + server:"testserver.local") |
| 69 | +letgenerator=ArgumentsSynchronize(config: cfg) |
| 70 | +letargs= generator.argumentsSynchronize(dryRun:true, forDisplay:false) |
| 71 | + |
| 72 | + #expect(args!=nil) |
| 73 | +} |
| 74 | + |
| 75 | +@Test("Push local→remote with keepdelete variations") |
| 76 | +func pushLocalToRemoteArgs()async{ |
| 77 | +SharedReference.shared.rsyncversion3=true |
| 78 | + |
| 79 | +letcfg=makeConfig() |
| 80 | +letgenerator=ArgumentsSynchronize(config: cfg) |
| 81 | + |
| 82 | +letargsKeep= generator.argumentsforpushlocaltoremotewithparameters(dryRun:false, |
| 83 | + forDisplay:false, |
| 84 | + keepdelete:true) |
| 85 | +letargsNoKeep= generator.argumentsforpushlocaltoremotewithparameters(dryRun:false, |
| 86 | + forDisplay:false, |
| 87 | + keepdelete:false) |
| 88 | + |
| 89 | + #expect(argsKeep!=nil) |
| 90 | + #expect(argsNoKeep!=nil) |
| 91 | +} |
| 92 | +} |
| 93 | + |
| 94 | +@MainActor |
| 95 | +@Suite("Deeplink URL Tests",.serialized) |
| 96 | +structDeeplinkURLTests{ |
| 97 | +@Test("Create estimate-and-synchronize URL with default profile") |
| 98 | +func createURLDefaultProfile()async{ |
| 99 | +leturl=DeeplinkURL().createURLestimateandsynchronize(valueprofile:nil) |
| 100 | + #expect(url!=nil) |
| 101 | + #expect(url!.absoluteString.contains("profile=Default")) |
| 102 | +} |
| 103 | + |
| 104 | +@Test("Create estimate-and-synchronize URL with custom profile") |
| 105 | +func createURLCustomProfile()async{ |
| 106 | +leturl=DeeplinkURL().createURLestimateandsynchronize(valueprofile:"Work") |
| 107 | + #expect(url!=nil) |
| 108 | + #expect(url!.absoluteString.contains("profile=Work")) |
| 109 | +} |
| 110 | +} |
| 111 | + |
| 112 | + |
| 113 | + |
13 | 114 | @MainActor |
14 | 115 | @Suite("Configuration Validation Tests",.serialized) |
15 | 116 | structVerifyConfigurationTests{ |
@@ -545,3 +646,5 @@ struct RsyncUITests { |
545 | 646 |
|
546 | 647 |
|
547 | 648 | } |
| 649 | +// swiftlint:enable all |
| 650 | + |