@@ -42,36 +42,36 @@ class BuildTriggerTests: AppTestCase {
42
42
latest: . defaultBranch,
43
43
reference: . branch( " main " ) )
44
44
try await v. save ( on: app. db)
45
- try BuildPair . all. forEach { pair in
46
- try Build ( id: UUID ( ) ,
47
- version: v,
48
- platform: pair. platform,
49
- status: . ok,
50
- swiftVersion: pair. swiftVersion)
51
- . save ( on: app. db) . wait ( )
45
+ for pair in BuildPair . all {
46
+ try await Build ( id: UUID ( ) ,
47
+ version: v,
48
+ platform: pair. platform,
49
+ status: . ok,
50
+ swiftVersion: pair. swiftVersion)
51
+ . save ( on: app. db)
52
52
}
53
53
}
54
54
// save two packages with partially completed builds
55
- try [ pkgIdIncomplete1, pkgIdIncomplete2] . forEach { id in
55
+ for id in [ pkgIdIncomplete1, pkgIdIncomplete2] {
56
56
let p = Package ( id: id, url: id. uuidString. url)
57
- try p. save ( on: app. db) . wait ( )
58
- try [ Version . Kind. defaultBranch, . release] . forEach { kind in
57
+ try await p. save ( on: app. db)
58
+ for kind in [ Version . Kind. defaultBranch, . release] {
59
59
let v = try Version ( package : p,
60
60
latest: kind,
61
61
reference: kind == . release
62
- ? . tag( 1 , 2 , 3 )
63
- : . branch( " main " ) )
64
- try v. save ( on: app. db) . wait ( )
65
- try BuildPair . all
62
+ ? . tag( 1 , 2 , 3 )
63
+ : . branch( " main " ) )
64
+ try await v. save ( on: app. db)
65
+ for pair in BuildPair . all
66
66
. dropFirst ( ) // skip one platform to create a build gap
67
- . forEach { pair in
68
- try Build ( id: UUID ( ) ,
69
- version: v,
70
- platform: pair. platform,
71
- status: . ok,
72
- swiftVersion: pair. swiftVersion)
73
- . save ( on: app. db) . wait ( )
74
- }
67
+ {
68
+ try await Build ( id: UUID ( ) ,
69
+ version: v,
70
+ platform: pair. platform,
71
+ status: . ok,
72
+ swiftVersion: pair. swiftVersion)
73
+ . save ( on: app. db)
74
+ }
75
75
}
76
76
}
77
77
@@ -90,13 +90,13 @@ class BuildTriggerTests: AppTestCase {
90
90
let pkgId = UUID ( )
91
91
let p = Package ( id: pkgId, url: pkgId. uuidString. url)
92
92
try await p. save ( on: app. db)
93
- try [ Version . Kind. defaultBranch, . release] . forEach { kind in
93
+ for kind in [ Version . Kind. defaultBranch, . release] {
94
94
let v = try Version ( package : p,
95
95
latest: kind,
96
96
reference: kind == . release
97
- ? . tag( 1 , 2 , 3 )
98
- : . branch( " main " ) )
99
- try v. save ( on: app. db) . wait ( )
97
+ ? . tag( 1 , 2 , 3 )
98
+ : . branch( " main " ) )
99
+ try await v. save ( on: app. db)
100
100
}
101
101
102
102
// MUT
@@ -157,26 +157,26 @@ class BuildTriggerTests: AppTestCase {
157
157
let pkgIdIncomplete2 = UUID ( )
158
158
Current . buildTriggerAllowList = { [ pkgIdIncomplete2] }
159
159
// save two packages with partially completed builds
160
- try [ pkgIdIncomplete1, pkgIdIncomplete2] . forEach { id in
160
+ for id in [ pkgIdIncomplete1, pkgIdIncomplete2] {
161
161
let p = Package ( id: id, url: id. uuidString. url)
162
- try p. save ( on: app. db) . wait ( )
163
- try [ Version . Kind. defaultBranch, . release] . forEach { kind in
162
+ try await p. save ( on: app. db)
163
+ for kind in [ Version . Kind. defaultBranch, . release] {
164
164
let v = try Version ( package : p,
165
165
latest: kind,
166
166
reference: kind == . release
167
167
? . tag( 1 , 2 , 3 )
168
168
: . branch( " main " ) )
169
- try v. save ( on: app. db) . wait ( )
170
- try BuildPair . all
169
+ try await v. save ( on: app. db)
170
+ for pair in BuildPair . all
171
171
. dropFirst ( ) // skip one platform to create a build gap
172
- . forEach { pair in
173
- try Build ( id: UUID ( ) ,
174
- version: v,
175
- platform: pair. platform,
176
- status: . ok,
177
- swiftVersion: pair. swiftVersion)
178
- . save ( on: app. db) . wait ( )
179
- }
172
+ {
173
+ try await Build ( id: UUID ( ) ,
174
+ version: v,
175
+ platform: pair. platform,
176
+ status: . ok,
177
+ swiftVersion: pair. swiftVersion)
178
+ . save ( on: app. db)
179
+ }
180
180
}
181
181
}
182
182
@@ -213,16 +213,16 @@ class BuildTriggerTests: AppTestCase {
213
213
latest: . release,
214
214
reference: . tag( 1 , 2 , 3 ) )
215
215
try await v. save ( on: app. db)
216
- try Build . Platform. allActive
217
- . filter { $0 != droppedPlatform } // skip one platform to create a build gap
218
- . forEach { platform in
219
- try SwiftVersion . allActive. forEach { swiftVersion in
220
- try Build ( id: UUID ( ) ,
221
- version: v,
222
- platform: platform,
223
- status: . ok,
224
- swiftVersion: swiftVersion)
225
- . save ( on: app. db) . wait ( )
216
+ for platform in Build . Platform. allActive
217
+ . filter ( { $0 != droppedPlatform } ) // skip one platform to create a build gap
218
+ {
219
+ for swiftVersion in SwiftVersion . allActive {
220
+ try await Build ( id: UUID ( ) ,
221
+ version: v,
222
+ platform: platform,
223
+ status: . ok,
224
+ swiftVersion: swiftVersion)
225
+ . save ( on: app. db)
226
226
}
227
227
}
228
228
}
@@ -303,16 +303,16 @@ class BuildTriggerTests: AppTestCase {
303
303
- documentation_targets: [t0]
304
304
""" ) )
305
305
try await v. save ( on: app. db)
306
- try Build . Platform. allActive
307
- . filter { $0 != . macosSpm } // skip macosSpm platform to create a build gap
308
- . forEach { platform in
309
- try SwiftVersion . allActive. forEach { swiftVersion in
310
- try Build ( id: UUID ( ) ,
311
- version: v,
312
- platform: platform,
313
- status: . ok,
314
- swiftVersion: swiftVersion)
315
- . save ( on: app. db) . wait ( )
306
+ for platform in Build . Platform. allActive
307
+ . filter ( { $0 != . macosSpm } ) // skip macosSpm platform to create a build gap
308
+ {
309
+ for swiftVersion in SwiftVersion . allActive {
310
+ try await Build ( id: UUID ( ) ,
311
+ version: v,
312
+ platform: platform,
313
+ status: . ok,
314
+ swiftVersion: swiftVersion)
315
+ . save ( on: app. db)
316
316
}
317
317
}
318
318
}
@@ -671,11 +671,11 @@ class BuildTriggerTests: AppTestCase {
671
671
Current . getStatusCount = { c, _ in 299 + triggerCount. withLockedValue { $0 } }
672
672
673
673
let pkgIds = [ UUID ( ) , UUID ( ) ]
674
- try pkgIds . forEach { id in
674
+ for id in pkgIds {
675
675
let p = Package ( id: id, url: id. uuidString. url)
676
- try p. save ( on: app. db) . wait ( )
677
- try Version ( id: UUID ( ) , package : p, latest: . defaultBranch, reference: . branch( " main " ) )
678
- . save ( on: app. db) . wait ( )
676
+ try await p. save ( on: app. db)
677
+ try await Version ( id: UUID ( ) , package : p, latest: . defaultBranch, reference: . branch( " main " ) )
678
+ . save ( on: app. db)
679
679
}
680
680
681
681
// MUT
@@ -705,7 +705,8 @@ class BuildTriggerTests: AppTestCase {
705
705
. save ( on: app. db)
706
706
// shift createdAt back to make build eligible from trimming
707
707
try await updateBuildCreatedAt ( id: . id2, addTimeInterval: - . hours ( 5 ) , on: app. db)
708
- XCTAssertEqual ( try Build . query ( on: app. db) . count ( ) . wait ( ) , 1 )
708
+ let db = app. db
709
+ try await XCTAssertEqualAsync ( try await Build . query ( on: db) . count ( ) , 1 )
709
710
710
711
// MUT
711
712
try await triggerBuilds ( on: app. db,
@@ -1019,7 +1020,8 @@ class BuildTriggerTests: AppTestCase {
1019
1020
try await updateBuildCreatedAt ( id: . id2, addTimeInterval: - . hours ( 5 ) , on: app. db)
1020
1021
}
1021
1022
1022
- XCTAssertEqual ( try Build . query ( on: app. db) . count ( ) . wait ( ) , 3 )
1023
+ let db = app. db
1024
+ try await XCTAssertEqualAsync ( try await Build . query ( on: db) . count ( ) , 3 )
1023
1025
1024
1026
// MUT
1025
1027
let deleteCount = try await trimBuilds ( on: app. db)
@@ -1055,7 +1057,8 @@ class BuildTriggerTests: AppTestCase {
1055
1057
try await updateBuildCreatedAt ( id: . id2, addTimeInterval: - . hours ( 5 ) , on: app. db)
1056
1058
}
1057
1059
1058
- XCTAssertEqual ( try Build . query ( on: app. db) . count ( ) . wait ( ) , 3 )
1060
+ let db = app. db
1061
+ try await XCTAssertEqualAsync ( try await Build . query ( on: db) . count ( ) , 3 )
1059
1062
1060
1063
// MUT
1061
1064
let deleteCount = try await trimBuilds ( on: app. db)
@@ -1111,7 +1114,8 @@ class BuildTriggerTests: AppTestCase {
1111
1114
}
1112
1115
}
1113
1116
1114
- XCTAssertEqual ( try Build . query ( on: app. db) . count ( ) . wait ( ) , 8 )
1117
+ let db = app. db
1118
+ try await XCTAssertEqualAsync ( try await Build . query ( on: db) . count ( ) , 8 )
1115
1119
1116
1120
// MUT
1117
1121
let deleteCount = try await trimBuilds ( on: app. db)
@@ -1167,7 +1171,8 @@ class BuildTriggerTests: AppTestCase {
1167
1171
1168
1172
// validate
1169
1173
XCTAssertEqual ( deleteCount, 0 )
1170
- XCTAssertEqual ( try Build . query ( on: app. db) . count ( ) . wait ( ) , 1 )
1174
+ let db = app. db
1175
+ try await XCTAssertEqualAsync ( try await Build . query ( on: db) . count ( ) , 1 )
1171
1176
1172
1177
// make build "old" by resetting "created_at"
1173
1178
try await updateBuildCreatedAt ( id: buildId, addTimeInterval: - . hours ( 4 ) , on: app. db)
@@ -1202,7 +1207,8 @@ class BuildTriggerTests: AppTestCase {
1202
1207
1203
1208
// validate
1204
1209
XCTAssertEqual ( deleteCount, 0 )
1205
- XCTAssertEqual ( try Build . query ( on: app. db) . count ( ) . wait ( ) , 1 )
1210
+ let db = app. db
1211
+ try await XCTAssertEqualAsync ( try await Build . query ( on: db) . count ( ) , 1 )
1206
1212
1207
1213
// make build "old" by resetting "created_at"
1208
1214
try await updateBuildCreatedAt ( id: buildId, addTimeInterval: - . hours ( 5 ) , on: app. db)
0 commit comments