@@ -18,6 +18,10 @@ import Testing
1818 SwiftlyVersion ( major: SwiftlyCore . version. major, minor: SwiftlyCore . version. minor, patch: SwiftlyCore . version. patch + 1 )
1919 }
2020
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+
2125 func runSelfUpdateTest( latestVersion: SwiftlyVersion ) async throws {
2226 try await SwiftlyTests . withTestHome {
2327 try await SwiftlyTests . withMockedSwiftlyVersion ( latestSwiftlyVersion: latestVersion) {
@@ -37,4 +41,26 @@ import Testing
3741 @Test func selfUpdateAlreadyUpToDate( ) async throws {
3842 try await self . runSelfUpdateTest ( latestVersion: SwiftlyCore . version)
3943 }
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+ }
4066}
0 commit comments