@@ -16,95 +16,7 @@ describe('Sessions - client/unit', function () {
16
16
} ) ;
17
17
} ) ;
18
18
19
- it ( 'should not throw a synchronous exception if sessions are not supported' , function ( ) {
20
- test . server . setMessageHandler ( request => {
21
- var doc = request . document ;
22
- if ( isHello ( doc ) ) {
23
- request . reply ( Object . assign ( { } , mock . HELLO ) ) ;
24
- } else if ( doc . endSessions ) {
25
- request . reply ( { ok : 1 } ) ;
26
- }
27
- } ) ;
28
-
29
- const client = new MongoClient ( `mongodb://${ test . server . uri ( ) } /test` ) ;
30
- return client . connect ( ) . then ( ( ) => {
31
- expect ( ( ) => client . startSession ( ) ) . to . not . throw (
32
- 'Current topology does not support sessions'
33
- ) ;
34
- return client . close ( ) ;
35
- } ) ;
36
- } ) ;
37
-
38
- it ( 'should throw an exception if sessions are not supported on some servers' , function ( ) {
39
- const replicaSetMock = new ReplSetFixture ( ) ;
40
- let testClient ;
41
- return replicaSetMock
42
- . setup ( { doNotInitHandlers : true } )
43
- . then ( ( ) => {
44
- replicaSetMock . firstSecondaryServer . setMessageHandler ( request => {
45
- var doc = request . document ;
46
- if ( isHello ( doc ) ) {
47
- const hello = replicaSetMock . firstSecondaryStates [ 0 ] ;
48
- hello . logicalSessionTimeoutMinutes = 20 ;
49
- request . reply ( hello ) ;
50
- } else if ( doc . endSessions ) {
51
- request . reply ( { ok : 1 } ) ;
52
- }
53
- } ) ;
54
-
55
- replicaSetMock . secondSecondaryServer . setMessageHandler ( request => {
56
- var doc = request . document ;
57
- if ( isHello ( doc ) ) {
58
- const hello = replicaSetMock . secondSecondaryStates [ 0 ] ;
59
- hello . logicalSessionTimeoutMinutes = 10 ;
60
- request . reply ( hello ) ;
61
- } else if ( doc . endSessions ) {
62
- request . reply ( { ok : 1 } ) ;
63
- }
64
- } ) ;
65
-
66
- replicaSetMock . arbiterServer . setMessageHandler ( request => {
67
- var doc = request . document ;
68
- if ( isHello ( doc ) ) {
69
- const hello = replicaSetMock . arbiterStates [ 0 ] ;
70
- hello . logicalSessionTimeoutMinutes = 30 ;
71
- request . reply ( hello ) ;
72
- } else if ( doc . endSessions ) {
73
- request . reply ( { ok : 1 } ) ;
74
- }
75
- } ) ;
76
-
77
- replicaSetMock . primaryServer . setMessageHandler ( request => {
78
- var doc = request . document ;
79
- if ( isHello ( doc ) ) {
80
- const hello = replicaSetMock . primaryStates [ 0 ] ;
81
- hello . logicalSessionTimeoutMinutes = null ;
82
- request . reply ( hello ) ;
83
- } else if ( doc . endSessions ) {
84
- request . reply ( { ok : 1 } ) ;
85
- }
86
- } ) ;
87
-
88
- return replicaSetMock . uri ( ) ;
89
- } )
90
- . then ( uri => {
91
- testClient = new MongoClient ( uri ) ;
92
- return testClient . connect ( ) ;
93
- } )
94
- . then ( client => {
95
- const session = client . startSession ( ) ;
96
- return client . db ( ) . collection ( 't' ) . insertOne ( { a : 1 } , { session } ) ;
97
- } )
98
- . then ( ( ) => {
99
- expect . fail ( 'Expected an error to be thrown about not supporting sessions' ) ;
100
- } )
101
- . catch ( error => {
102
- expect ( error . message ) . to . equal ( 'Current topology does not support sessions' ) ;
103
- } )
104
- . finally ( ( ) => ( testClient ? testClient . close ( ) : null ) ) ;
105
- } ) ;
106
-
107
- it ( 'should return a client session when requested if the topology supports it' , function ( done ) {
19
+ it ( 'should return a client session when requested' , function ( done ) {
108
20
test . server . setMessageHandler ( request => {
109
21
var doc = request . document ;
110
22
if ( isHello ( doc ) ) {
0 commit comments