@@ -18,6 +18,10 @@ import Testing
18
18
SwiftlyVersion ( major: SwiftlyCore . version. major, minor: SwiftlyCore . version. minor, patch: SwiftlyCore . version. patch + 1 )
19
19
}
20
20
21
+ private static var newDevVersion : SwiftlyVersion {
22
+ SwiftlyVersion ( major: SwiftlyCore . version. major, minor: SwiftlyCore . version. minor, patch: SwiftlyCore . version. patch + 1 , suffix: " dev " )
23
+ }
24
+
21
25
func runSelfUpdateTest( latestVersion: SwiftlyVersion ) async throws {
22
26
try await SwiftlyTests . withTestHome {
23
27
try await SwiftlyTests . withMockedSwiftlyVersion ( latestSwiftlyVersion: latestVersion) {
@@ -37,4 +41,26 @@ import Testing
37
41
@Test func selfUpdateAlreadyUpToDate( ) async throws {
38
42
try await self . runSelfUpdateTest ( latestVersion: SwiftlyCore . version)
39
43
}
44
+
45
+ @Test func selfUpdateToUserSpecifiedVersion( ) async throws {
46
+ try await SwiftlyTests . withTestHome {
47
+ // GIVEN: swiftly is installed, and at the latest published version
48
+ try await SwiftlyTests . withMockedSwiftlyVersion ( latestSwiftlyVersion: SwiftlyCore . version) {
49
+ // WHEN: An attempt is made to self-update to an equal version
50
+ var updatedVersion = try await SelfUpdate . execute ( SwiftlyTests . ctx, verbose: true , version: SwiftlyCore . version)
51
+ // THEN: There is no change to the swiftly version
52
+ #expect( updatedVersion == SwiftlyCore . version)
53
+
54
+ // WHEN: An attempt is made to self-update to an older version
55
+ updatedVersion = try await SelfUpdate . execute ( SwiftlyTests . ctx, verbose: true , version: SwiftlyVersion ( major: SwiftlyCore . version. major - 1 , minor: 0 , patch: 0 ) )
56
+ // THEN: There is no change to the swiftly version
57
+ #expect( updatedVersion == SwiftlyCore . version)
58
+
59
+ // WHEN: An attempt is made to self-update to a newer development version
60
+ updatedVersion = try await SelfUpdate . execute ( SwiftlyTests . ctx, verbose: true , version: Self . newDevVersion)
61
+ // THEN: swiftly is updated to the new version
62
+ #expect( updatedVersion == Self . newDevVersion)
63
+ }
64
+ }
65
+ }
40
66
}
0 commit comments