4
4
Collection ,
5
5
GridFSBucket ,
6
6
Document ,
7
- HostAddress
7
+ HostAddress ,
8
+ ServerApiVersion
8
9
} from '../../../src/index' ;
9
10
import { ReadConcern } from '../../../src/read_concern' ;
10
11
import { WriteConcern } from '../../../src/write_concern' ;
@@ -30,7 +31,7 @@ import type {
30
31
CommandStartedEvent ,
31
32
CommandSucceededEvent
32
33
} from '../../../src/cmap/command_monitoring_events' ;
33
- import { patchCollectionOptions , patchDbOptions } from './unified-utils' ;
34
+ import { makeConnectionString , patchCollectionOptions , patchDbOptions } from './unified-utils' ;
34
35
import { expect } from 'chai' ;
35
36
import { TestConfiguration , trace } from './runner' ;
36
37
@@ -53,7 +54,7 @@ export type CmapEvent =
53
54
54
55
function serverApiConfig ( ) {
55
56
if ( process . env . MONGODB_API_VERSION ) {
56
- return { version : process . env . MONGODB_API_VERSION } ;
57
+ return { version : process . env . MONGODB_API_VERSION as ServerApiVersion } ;
57
58
}
58
59
}
59
60
@@ -102,12 +103,12 @@ export class UnifiedMongoClient extends MongoClient {
102
103
connectionCheckedInEvent : 'connectionCheckedIn'
103
104
} as const ;
104
105
105
- constructor ( url : string , description : ClientEntity ) {
106
- super ( url , {
106
+ constructor ( uri : string , description : ClientEntity ) {
107
+ super ( uri , {
107
108
monitorCommands : true ,
108
- ...description . uriOptions ,
109
109
serverApi : description . serverApi ? description . serverApi : serverApiConfig ( )
110
110
} ) ;
111
+
111
112
this . commandEvents = [ ] ;
112
113
this . cmapEvents = [ ] ;
113
114
this . failPoints = [ ] ;
@@ -329,7 +330,10 @@ export class EntitiesMap<E = Entity> extends Map<string, E> {
329
330
const useMultipleMongoses =
330
331
( config . topologyType === 'LoadBalanced' || config . topologyType === 'Sharded' ) &&
331
332
entity . client . useMultipleMongoses ;
332
- const uri = config . url ( { useMultipleMongoses } ) ;
333
+ const uri = makeConnectionString (
334
+ config . url ( { useMultipleMongoses } ) ,
335
+ entity . client . uriOptions
336
+ ) ;
333
337
const client = new UnifiedMongoClient ( uri , entity . client ) ;
334
338
await client . connect ( ) ;
335
339
map . set ( entity . client . id , client ) ;
0 commit comments