Skip to content

Commit 089e0a6

Browse files
committed
Fix ActorIsolated related warnings
1 parent b23054b commit 089e0a6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Tests/AppTests/SocialTests.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
@testable import App
1616

1717
import InlineSnapshotTesting
18+
import NIOConcurrencyHelpers
1819
import XCTVapor
1920

2021

@@ -190,16 +191,16 @@ class SocialTests: AppTestCase {
190191
let jpr = try await Package.fetchCandidate(app.db, id: pkg.id!)
191192
let versions = try await Analyze.updateLatestVersions(on: app.db, package: jpr)
192193

193-
let posted = ActorIsolated(0)
194-
Current.mastodonPost = { _, _ in await posted.increment() }
194+
let posted: NIOLockedValueBox<Int> = .init(0)
195+
Current.mastodonPost = { _, _ in posted.withLockedValue { $0 += 1 } }
195196

196197
// MUT
197198
try await Social.postToFirehose(client: app.client,
198199
package: jpr,
199200
versions: versions)
200201

201202
// validate
202-
try await XCTAssertEqualAsync(await posted.value, 2)
203+
try await XCTAssertEqualAsync(posted.withLockedValue { $0 }, 2)
203204
}
204205

205206
func test_postToFirehose_only_latest() async throws {
@@ -218,10 +219,10 @@ class SocialTests: AppTestCase {
218219
let jpr = try await Package.fetchCandidate(app.db, id: pkg.id!)
219220
let versions = try await Analyze.updateLatestVersions(on: app.db, package: jpr)
220221

221-
let posted = ActorIsolated(0)
222+
let posted: NIOLockedValueBox<Int> = .init(0)
222223
Current.mastodonPost = { _, msg in
223224
XCTAssertTrue(msg.contains("v2.0.0"))
224-
await posted.increment()
225+
posted.withLockedValue { $0 += 1 }
225226
}
226227

227228
// MUT
@@ -230,7 +231,7 @@ class SocialTests: AppTestCase {
230231
versions: versions)
231232

232233
// validate
233-
try await XCTAssertEqualAsync(await posted.value, 1)
234+
try await XCTAssertEqualAsync(posted.withLockedValue { $0 }, 1)
234235
}
235236

236237
func test_urlEncoding() async throws {

0 commit comments

Comments
 (0)