@@ -73,27 +73,32 @@ describe('Index Management Prose Tests', function () {
73
73
}
74
74
} ,
75
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' ,
82
- definition : {
83
- mappings : { dynamic : false }
84
- }
85
- } ) ;
86
-
87
- const [ index ] = await waitForIndexes (
88
- collection ,
89
- indexes => indexes . every ( index => index . queryable ) ,
90
- 'test-search-index'
91
- ) ;
92
-
93
- expect ( index ) . to . exist ;
94
- expect ( index )
95
- . to . have . property ( 'latestDefinition' )
96
- . to . deep . equal ( { mappings : { dynamic : false } } ) ;
76
+ try {
77
+ const collection = await client
78
+ . db ( 'test-db' )
79
+ . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
80
+
81
+ await collection . createSearchIndex ( {
82
+ name : 'test-search-index' ,
83
+ definition : {
84
+ mappings : { dynamic : false }
85
+ }
86
+ } ) ;
87
+
88
+ const [ index ] = await waitForIndexes (
89
+ collection ,
90
+ indexes => indexes . every ( index => index . queryable ) ,
91
+ 'test-search-index'
92
+ ) ;
93
+
94
+ expect ( index ) . to . exist ;
95
+ expect ( index )
96
+ . to . have . property ( 'latestDefinition' )
97
+ . to . deep . equal ( { mappings : { dynamic : false } } ) ;
98
+ } catch ( error ) {
99
+ console . error ( { error } ) ;
100
+ throw error ;
101
+ }
97
102
}
98
103
) ;
99
104
@@ -105,38 +110,43 @@ describe('Index Management Prose Tests', function () {
105
110
}
106
111
} ,
107
112
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 }
113
+ try {
114
+ const collection = await client
115
+ . db ( 'test-db' )
116
+ . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
117
+
118
+ const indexDefinitions = [
119
+ {
120
+ name : 'test-search-index-1' ,
121
+ definition : {
122
+ mappings : { dynamic : false }
123
+ }
124
+ } ,
125
+ {
126
+ name : 'test-search-index-2' ,
127
+ definition : {
128
+ mappings : { dynamic : false }
129
+ }
123
130
}
124
- }
125
- ] ;
131
+ ] ;
126
132
127
- await collection . createSearchIndexes ( indexDefinitions ) ;
133
+ await collection . createSearchIndexes ( indexDefinitions ) ;
128
134
129
- const indexes = await waitForIndexes ( collection , indexes =>
130
- indexes . every ( index => index . queryable )
131
- ) ;
135
+ const indexes = await waitForIndexes ( collection , indexes =>
136
+ indexes . every ( index => index . queryable )
137
+ ) ;
132
138
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 ;
139
+ for ( const indexDescription of indexDefinitions ) {
140
+ const index = indexes . find ( ( { name } ) => name === indexDescription . name ) ;
141
+ expect ( index , `expected ${ indexDescription . name } to exist` ) . to . exist ;
136
142
137
- expect ( index )
138
- . to . have . property ( 'latestDefinition' )
139
- . to . deep . equal ( { mappings : { dynamic : false } } ) ;
143
+ expect ( index )
144
+ . to . have . property ( 'latestDefinition' )
145
+ . to . deep . equal ( { mappings : { dynamic : false } } ) ;
146
+ }
147
+ } catch ( error ) {
148
+ console . error ( { error } ) ;
149
+ throw error ;
140
150
}
141
151
}
142
152
) ;
@@ -149,32 +159,37 @@ describe('Index Management Prose Tests', function () {
149
159
}
150
160
} ,
151
161
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
- } ) ;
162
-
163
- await waitForIndexes (
164
- collection ,
165
- indexes => indexes . every ( index => index . queryable ) ,
166
- 'test-search-index'
167
- ) ;
168
-
169
- await collection . dropSearchIndex ( 'test-search-index' ) ;
170
-
171
- const indexes = await waitForIndexes (
172
- collection ,
173
- indexes => indexes . length === 0 ,
174
- 'test-search-index'
175
- ) ;
162
+ try {
163
+ const collection = await client
164
+ . db ( 'test-db' )
165
+ . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
176
166
177
- expect ( indexes ) . to . deep . equal ( [ ] ) ;
167
+ await collection . createSearchIndex ( {
168
+ name : 'test-search-index' ,
169
+ definition : {
170
+ mappings : { dynamic : false }
171
+ }
172
+ } ) ;
173
+
174
+ await waitForIndexes (
175
+ collection ,
176
+ indexes => indexes . every ( index => index . queryable ) ,
177
+ 'test-search-index'
178
+ ) ;
179
+
180
+ await collection . dropSearchIndex ( 'test-search-index' ) ;
181
+
182
+ const indexes = await waitForIndexes (
183
+ collection ,
184
+ indexes => indexes . length === 0 ,
185
+ 'test-search-index'
186
+ ) ;
187
+
188
+ expect ( indexes ) . to . deep . equal ( [ ] ) ;
189
+ } catch ( error ) {
190
+ console . error ( { error } ) ;
191
+ throw error ;
192
+ }
178
193
}
179
194
) ;
180
195
@@ -186,35 +201,40 @@ describe('Index Management Prose Tests', function () {
186
201
}
187
202
} ,
188
203
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
- } ) ;
199
-
200
- await waitForIndexes (
201
- collection ,
202
- indexes => indexes . every ( index => index . queryable ) ,
203
- 'test-search-index'
204
- ) ;
205
-
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 } } ) ;
204
+ try {
205
+ const collection = await client
206
+ . db ( 'test-db' )
207
+ . createCollection ( new ObjectId ( ) . toHexString ( ) ) ;
208
+
209
+ await collection . createSearchIndex ( {
210
+ name : 'test-search-index' ,
211
+ definition : {
212
+ mappings : { dynamic : false }
213
+ }
214
+ } ) ;
215
+
216
+ await waitForIndexes (
217
+ collection ,
218
+ indexes => indexes . every ( index => index . queryable ) ,
219
+ 'test-search-index'
220
+ ) ;
221
+
222
+ await collection . updateSearchIndex ( 'test-search-index' , { mappings : { dynamic : true } } ) ;
223
+
224
+ const [ updatedIndex ] = await waitForIndexes (
225
+ collection ,
226
+ indexes => indexes . every ( index => index . queryable && index . status === 'READY' ) ,
227
+ 'test-search-index'
228
+ ) ;
229
+
230
+ expect ( updatedIndex ) . to . have . property ( 'name' , 'test-search-index' ) ;
231
+ expect ( updatedIndex )
232
+ . to . have . property ( 'latestDefinition' )
233
+ . to . deep . equal ( { mappings : { dynamic : true } } ) ;
234
+ } catch ( error ) {
235
+ console . error ( { error } ) ;
236
+ throw error ;
237
+ }
218
238
}
219
239
) ;
220
240
0 commit comments