@@ -47,7 +47,7 @@ describe('Index Management Prose Tests', function () {
47
47
} ) ;
48
48
49
49
beforeEach ( function ( ) {
50
- if ( lt ( process . version , '18.0' ) ) {
50
+ if ( lt ( process . version , '18.0.0 ' ) ) {
51
51
this . currentTest ! . skipReason = 'Test requires Node18+' ;
52
52
this . skip ( ) ;
53
53
}
@@ -61,127 +61,175 @@ describe('Index Management Prose Tests', function () {
61
61
} ) ;
62
62
63
63
afterEach ( async ( ) => {
64
- await client . close ( ) ;
65
- timeoutController . clear ( false ) ;
64
+ await client ? .close ( ) ;
65
+ timeoutController ? .clear ( false ) ;
66
66
} ) ;
67
67
68
- it ( 'Case 1: Driver can successfully create and list search indexes' , async function ( ) {
69
- const collection = await client . db ( 'test-db' ) . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
70
-
71
- await collection . createSearchIndex ( {
72
- name : 'test-search-index' ,
73
- definition : {
74
- mappings : { dynamic : false }
68
+ it (
69
+ 'Case 1: Driver can successfully create and list search indexes' ,
70
+ {
71
+ requires : {
72
+ mongodb : '>=7.0'
75
73
}
76
- } ) ;
77
-
78
- const [ index ] = await waitForIndexes (
79
- collection ,
80
- indexes => indexes . every ( index => index . queryable ) ,
81
- 'test-search-index'
82
- ) ;
83
-
84
- expect ( index ) . to . exist ;
85
- expect ( index )
86
- . to . have . property ( 'latestDefinition' )
87
- . to . deep . equal ( { mappings : { dynamic : false } } ) ;
88
- } ) ;
89
-
90
- it ( 'Case 2: Driver can successfully create multiple indexes in batch' , async function ( ) {
91
- const collection = await client . db ( 'test-db' ) . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
92
-
93
- const indexDefinitions = [
94
- {
95
- name : 'test-search-index-1' ,
74
+ } ,
75
+ async function ( ) {
76
+ const collection = await client
77
+ . db ( 'test-db' )
78
+ . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
79
+
80
+ await collection . createSearchIndex ( {
81
+ name : 'test-search-index' ,
96
82
definition : {
97
83
mappings : { dynamic : false }
98
84
}
99
- } ,
100
- {
101
- name : 'test-search-index-2' ,
102
- definition : {
103
- mappings : { dynamic : false }
104
- }
105
- }
106
- ] ;
107
-
108
- await collection . createSearchIndexes ( indexDefinitions ) ;
85
+ } ) ;
109
86
110
- const indexes = await waitForIndexes ( collection , indexes =>
111
- indexes . every ( index => index . queryable )
112
- ) ;
113
-
114
- for ( const indexDescription of indexDefinitions ) {
115
- const index = indexes . find ( ( { name } ) => name === indexDescription . name ) ;
116
- expect ( index , `expected ${ indexDescription . name } to exist` ) . to . exist ;
87
+ const [ index ] = await waitForIndexes (
88
+ collection ,
89
+ indexes => indexes . every ( index => index . queryable ) ,
90
+ 'test-search-index'
91
+ ) ;
117
92
93
+ expect ( index ) . to . exist ;
118
94
expect ( index )
119
95
. to . have . property ( 'latestDefinition' )
120
96
. to . deep . equal ( { mappings : { dynamic : false } } ) ;
121
97
}
122
- } ) ;
98
+ ) ;
99
+
100
+ it (
101
+ 'Case 2: Driver can successfully create multiple indexes in batch' ,
102
+ {
103
+ requires : {
104
+ mongodb : '>=7.0'
105
+ }
106
+ } ,
107
+ async function ( ) {
108
+ const collection = await client
109
+ . db ( 'test-db' )
110
+ . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
111
+
112
+ const indexDefinitions = [
113
+ {
114
+ name : 'test-search-index-1' ,
115
+ definition : {
116
+ mappings : { dynamic : false }
117
+ }
118
+ } ,
119
+ {
120
+ name : 'test-search-index-2' ,
121
+ definition : {
122
+ mappings : { dynamic : false }
123
+ }
124
+ }
125
+ ] ;
123
126
124
- it ( 'Case 3: Driver can successfully drop search indexes' , async function ( ) {
125
- const collection = await client . db ( 'test-db' ) . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
127
+ await collection . createSearchIndexes ( indexDefinitions ) ;
126
128
127
- await collection . createSearchIndex ( {
128
- name : 'test-search-index' ,
129
- definition : {
130
- mappings : { dynamic : false }
129
+ const indexes = await waitForIndexes ( collection , indexes =>
130
+ indexes . every ( index => index . queryable )
131
+ ) ;
132
+
133
+ for ( const indexDescription of indexDefinitions ) {
134
+ const index = indexes . find ( ( { name } ) => name === indexDescription . name ) ;
135
+ expect ( index , `expected ${ indexDescription . name } to exist` ) . to . exist ;
136
+
137
+ expect ( index )
138
+ . to . have . property ( 'latestDefinition' )
139
+ . to . deep . equal ( { mappings : { dynamic : false } } ) ;
131
140
}
132
- } ) ;
141
+ }
142
+ ) ;
133
143
134
- await waitForIndexes (
135
- collection ,
136
- indexes => indexes . every ( index => index . queryable ) ,
137
- 'test-search-index'
138
- ) ;
144
+ it (
145
+ 'Case 3: Driver can successfully drop search indexes' ,
146
+ {
147
+ requires : {
148
+ mongodb : '>=7.0'
149
+ }
150
+ } ,
151
+ async function ( ) {
152
+ const collection = await client
153
+ . db ( 'test-db' )
154
+ . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
155
+
156
+ await collection . createSearchIndex ( {
157
+ name : 'test-search-index' ,
158
+ definition : {
159
+ mappings : { dynamic : false }
160
+ }
161
+ } ) ;
139
162
140
- await collection . dropSearchIndex ( 'test-search-index' ) ;
163
+ await waitForIndexes (
164
+ collection ,
165
+ indexes => indexes . every ( index => index . queryable ) ,
166
+ 'test-search-index'
167
+ ) ;
141
168
142
- const indexes = await waitForIndexes (
143
- collection ,
144
- indexes => indexes . length === 0 ,
145
- 'test-search-index'
146
- ) ;
169
+ await collection . dropSearchIndex ( 'test-search-index' ) ;
147
170
148
- expect ( indexes ) . to . deep . equal ( [ ] ) ;
149
- } ) ;
171
+ const indexes = await waitForIndexes (
172
+ collection ,
173
+ indexes => indexes . length === 0 ,
174
+ 'test-search-index'
175
+ ) ;
150
176
151
- it ( 'Case 4: Driver can update a search index' , async function ( ) {
152
- const collection = await client . db ( 'test-db' ) . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
177
+ expect ( indexes ) . to . deep . equal ( [ ] ) ;
178
+ }
179
+ ) ;
153
180
154
- await collection . createSearchIndex ( {
155
- name : 'test-search-index' ,
156
- definition : {
157
- mappings : { dynamic : false }
181
+ it (
182
+ 'Case 4: Driver can update a search index' ,
183
+ {
184
+ requires : {
185
+ mongodb : '>=7.0'
158
186
}
159
- } ) ;
160
-
161
- await waitForIndexes (
162
- collection ,
163
- indexes => indexes . every ( index => index . queryable ) ,
164
- 'test-search-index'
165
- ) ;
166
-
167
- await collection . updateSearchIndex ( 'test-search-index' , { mappings : { dynamic : true } } ) ;
168
-
169
- const [ updatedIndex ] = await waitForIndexes (
170
- collection ,
171
- indexes => indexes . every ( index => index . queryable && index . status === 'READY' ) ,
172
- 'test-search-index'
173
- ) ;
174
-
175
- expect ( updatedIndex ) . to . have . property ( 'name' , 'test-search-index' ) ;
176
- expect ( updatedIndex )
177
- . to . have . property ( 'latestDefinition' )
178
- . to . deep . equal ( { mappings : { dynamic : true } } ) ;
179
- } ) ;
187
+ } ,
188
+ async function ( ) {
189
+ const collection = await client
190
+ . db ( 'test-db' )
191
+ . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
192
+
193
+ await collection . createSearchIndex ( {
194
+ name : 'test-search-index' ,
195
+ definition : {
196
+ mappings : { dynamic : false }
197
+ }
198
+ } ) ;
180
199
181
- it ( 'Case 5: `dropSearchIndex` suppresses namespace not found errors' , async function ( ) {
182
- const collection = await client . db ( 'test-db' ) . collection ( new ObjectId ( ) . toHexString ( ) ) ;
200
+ await waitForIndexes (
201
+ collection ,
202
+ indexes => indexes . every ( index => index . queryable ) ,
203
+ 'test-search-index'
204
+ ) ;
183
205
184
- await collection . dropSearchIndex ( 'test-search-index' ) ;
185
- } ) ;
206
+ await collection . updateSearchIndex ( 'test-search-index' , { mappings : { dynamic : true } } ) ;
207
+
208
+ const [ updatedIndex ] = await waitForIndexes (
209
+ collection ,
210
+ indexes => indexes . every ( index => index . queryable && index . status === 'READY' ) ,
211
+ 'test-search-index'
212
+ ) ;
213
+
214
+ expect ( updatedIndex ) . to . have . property ( 'name' , 'test-search-index' ) ;
215
+ expect ( updatedIndex )
216
+ . to . have . property ( 'latestDefinition' )
217
+ . to . deep . equal ( { mappings : { dynamic : true } } ) ;
218
+ }
219
+ ) ;
220
+
221
+ it (
222
+ 'Case 5: `dropSearchIndex` suppresses namespace not found errors' ,
223
+ {
224
+ requires : {
225
+ mongodb : '>=7.0'
226
+ }
227
+ } ,
228
+ async function ( ) {
229
+ const collection = await client . db ( 'test-db' ) . collection ( new ObjectId ( ) . toHexString ( ) ) ;
230
+
231
+ await collection . dropSearchIndex ( 'test-search-index' ) ;
232
+ }
233
+ ) ;
186
234
} ) ;
187
235
} ) ;
0 commit comments