File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,31 @@ final class AsyncAwaitTests: MongoSwiftTestCase {
113113 }
114114 }
115115 }
116+
117+ func testConcurrentClientUsage( ) throws {
118+ testAsync {
119+ try await self . withTestNamespace { _, db, _ in
120+ defer {
121+ db. syncDropOrFail ( )
122+ }
123+ try await withThrowingTaskGroup ( of: Int . self) { group in
124+ for i in 1 ... 20 {
125+ group. addTask {
126+ let coll = db. collection ( " concurrent-client-test- \( i) " )
127+ for j in 1 ... 100 {
128+ try await coll. insertOne ( [ " _id " : . int32( Int32 ( j) ) ] )
129+ }
130+ return try await coll. countDocuments ( )
131+ }
132+ }
133+
134+ for try await result in group {
135+ expect ( result) . to ( equal ( 100 ) )
136+ }
137+ }
138+ }
139+ }
140+ }
116141}
117142
118143final class MongoCursorAsyncAwaitTests: MongoSwiftTestCase {
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ extension MongoClient {
5757}
5858
5959extension MongoDatabase {
60- fileprivate func syncDropOrFail( ) {
60+ internal func syncDropOrFail( ) {
6161 do {
6262 try self . drop ( ) . wait ( )
6363 } catch {
You can’t perform that action at this time.
0 commit comments