Skip to content

Commit 6c7abae

Browse files
committed
Adapt integration suite to new elasticsearch package
- On success, elasticsearch errors are now *null* rather than *undefined*, which broke some tests. Now we just check that `err` is falsy rather than strictly equal to `undefined`. - Payload moved from res to res.body - `statusCode` moved from top level callback arg to `res.statuCode` - normalized function formatting for tests to `(err, { body })` there were a few different styles/indentations.
1 parent 5be1d38 commit 6c7abae

12 files changed

+158
-159
lines changed

integration/address_matching.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ module.exports.tests.functional = function(test, common){
6868
body: { query: { bool: { must: [
6969
{ match: { 'address_parts.number': 30 } }
7070
]}}}
71-
}, function( err, res ){
72-
t.equal( err, undefined );
73-
t.equal( getTotalHits(res.hits), 1, 'match street number' );
71+
}, (err, { body }) => {
72+
t.false(err);
73+
t.equal( getTotalHits(body.hits), 1, 'match street number' );
7474
done();
7575
});
7676
});
@@ -82,9 +82,9 @@ module.exports.tests.functional = function(test, common){
8282
body: { query: { bool: { must: [
8383
{ match_phrase: { 'address_parts.street': 'west 26th street' } }
8484
]}}}
85-
}, function( err, res ){
86-
t.equal( err, undefined );
87-
t.equal( getTotalHits(res.hits), 2, 'match street name' );
85+
}, (err, { body }) => {
86+
t.false(err);
87+
t.equal( getTotalHits(body.hits), 2, 'match street name' );
8888
done();
8989
});
9090
});
@@ -96,9 +96,9 @@ module.exports.tests.functional = function(test, common){
9696
body: { query: { bool: { must: [
9797
{ match_phrase: { 'address_parts.street': 'W 26th ST' } }
9898
]}}}
99-
}, function( err, res ){
100-
t.equal( err, undefined );
101-
t.equal( getTotalHits(res.hits), 2, 'match street name - abbr' );
99+
}, (err, { body }) => {
100+
t.false(err);
101+
t.equal( getTotalHits(body.hits), 2, 'match street name - abbr' );
102102
done();
103103
});
104104
});
@@ -110,9 +110,9 @@ module.exports.tests.functional = function(test, common){
110110
body: { query: { bool: { must: [
111111
{ match: { 'address_parts.zip': '10010' } }
112112
]}}}
113-
}, function( err, res ){
114-
t.equal( err, undefined );
115-
t.equal( getTotalHits(res.hits), 3, 'match zip - numeric' );
113+
}, (err, { body }) => {
114+
t.false(err);
115+
t.equal( getTotalHits(body.hits), 3, 'match zip - numeric' );
116116
done();
117117
});
118118
});
@@ -124,9 +124,9 @@ module.exports.tests.functional = function(test, common){
124124
body: { query: { bool: { must: [
125125
{ match: { 'address_parts.zip': 'e24dn' } }
126126
]}}}
127-
}, function( err, res ){
128-
t.equal( err, undefined );
129-
t.equal( getTotalHits(res.hits), 1, 'match zip - string' );
127+
}, (err, { body }) => {
128+
t.false(err);
129+
t.equal( getTotalHits(body.hits), 1, 'match zip - string' );
130130
done();
131131
});
132132
});
@@ -138,9 +138,9 @@ module.exports.tests.functional = function(test, common){
138138
body: { query: { bool: { must: [
139139
{ match: { 'address_parts.zip': '100-10' } }
140140
]}}}
141-
}, function( err, res ){
142-
t.equal( err, undefined );
143-
t.equal( getTotalHits(res.hits), 3, 'match zip - numeric - punct' );
141+
}, (err, { body }) => {
142+
t.false(err);
143+
t.equal( getTotalHits(body.hits), 3, 'match zip - numeric - punct' );
144144
done();
145145
});
146146
});
@@ -152,9 +152,9 @@ module.exports.tests.functional = function(test, common){
152152
body: { query: { bool: { must: [
153153
{ match: { 'address_parts.zip': '10 0 10' } }
154154
]}}}
155-
}, function( err, res ){
156-
t.equal( err, undefined );
157-
t.equal( getTotalHits(res.hits), 3, 'match zip - numeric - whitespace' );
155+
}, (err, { body }) => {
156+
t.false(err);
157+
t.equal( getTotalHits(body.hits), 3, 'match zip - numeric - whitespace' );
158158
done();
159159
});
160160
});
@@ -166,9 +166,9 @@ module.exports.tests.functional = function(test, common){
166166
body: { query: { bool: { must: [
167167
{ match: { 'address_parts.zip': 'E2-4DN' } }
168168
]}}}
169-
}, function( err, res ){
170-
t.equal( err, undefined );
171-
t.equal( getTotalHits(res.hits), 1, 'match zip - string - punct' );
169+
}, (err, { body }) => {
170+
t.false(err);
171+
t.equal( getTotalHits(body.hits), 1, 'match zip - string - punct' );
172172
done();
173173
});
174174
});
@@ -180,9 +180,9 @@ module.exports.tests.functional = function(test, common){
180180
body: { query: { bool: { must: [
181181
{ match: { 'address_parts.zip': 'E2 4DN' } }
182182
]}}}
183-
}, function( err, res ){
184-
t.equal( err, undefined );
185-
t.equal( getTotalHits(res.hits), 1, 'match zip - string - whitespace' );
183+
}, (err, { body }) => {
184+
t.false(err);
185+
t.equal( getTotalHits(body.hits), 1, 'match zip - string - whitespace' );
186186
done();
187187
});
188188
});
@@ -289,10 +289,10 @@ module.exports.tests.venue_vs_address = function(test, common){
289289
}
290290
}
291291
}
292-
}, function( err, res ){
293-
t.equal( err, undefined );
294-
t.equal( getTotalHits(res.hits), TOTAL_ADDRESS_DOCS+1, 'matched all docs' );
295-
t.equal( res.hits.hits[TOTAL_ADDRESS_DOCS]._id, '1', 'exact name match first' );
292+
}, (err, { body }) => {
293+
t.false(err);
294+
t.equal( getTotalHits(body.hits), TOTAL_ADDRESS_DOCS+1, 'matched all docs' );
295+
t.equal( body.hits.hits[TOTAL_ADDRESS_DOCS]._id, '1', 'exact name match first' );
296296
done();
297297
});
298298
});

integration/admin_abbreviations.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ module.exports.tests.synonyms = function (test, common) {
5555
}
5656
}
5757
}
58-
}, (err, res) => {
59-
t.equal(err, undefined);
60-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
61-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
58+
}, (err, { body }) => {
59+
t.false(err);
60+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
61+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
6262
done();
6363
});
6464
});
@@ -77,10 +77,10 @@ module.exports.tests.synonyms = function (test, common) {
7777
}
7878
}
7979
}
80-
}, (err, res) => {
81-
t.equal(err, undefined);
82-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
83-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
80+
}, (err, { body }) => {
81+
t.false(err);
82+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
83+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
8484
done();
8585
});
8686
});
@@ -99,10 +99,10 @@ module.exports.tests.synonyms = function (test, common) {
9999
}
100100
}
101101
}
102-
}, (err, res) => {
103-
t.equal(err, undefined);
104-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
105-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
102+
}, (err, { body }) => {
103+
t.false(err);
104+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
105+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
106106
done();
107107
});
108108
});
@@ -121,10 +121,10 @@ module.exports.tests.synonyms = function (test, common) {
121121
}
122122
}
123123
}
124-
}, (err, res) => {
125-
t.equal(err, undefined);
126-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
127-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
124+
}, (err, { body }) => {
125+
t.false(err);
126+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
127+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
128128
done();
129129
});
130130
});
@@ -177,10 +177,10 @@ module.exports.tests.synonyms = function (test, common) {
177177
}
178178
}
179179
}
180-
}, (err, res) => {
181-
t.equal(err, undefined);
182-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
183-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
180+
}, (err, { body }) => {
181+
t.false(err);
182+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
183+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
184184
done();
185185
});
186186
});
@@ -199,10 +199,10 @@ module.exports.tests.synonyms = function (test, common) {
199199
}
200200
}
201201
}
202-
}, (err, res) => {
203-
t.equal(err, undefined);
204-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
205-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
202+
}, (err, { body }) => {
203+
t.false(err);
204+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
205+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
206206
done();
207207
});
208208
});
@@ -221,10 +221,10 @@ module.exports.tests.synonyms = function (test, common) {
221221
}
222222
}
223223
}
224-
}, (err, res) => {
225-
t.equal(err, undefined);
226-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
227-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
224+
}, (err, { body }) => {
225+
t.false(err);
226+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
227+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
228228
done();
229229
});
230230
});
@@ -243,10 +243,10 @@ module.exports.tests.synonyms = function (test, common) {
243243
}
244244
}
245245
}
246-
}, (err, res) => {
247-
t.equal(err, undefined);
248-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
249-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
246+
}, (err, { body }) => {
247+
t.false(err);
248+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
249+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
250250
done();
251251
});
252252
});
@@ -311,10 +311,10 @@ module.exports.tests.synonyms = function (test, common) {
311311
}
312312
}
313313
}
314-
}, (err, res) => {
315-
t.equal(err, undefined);
316-
t.equal(getTotalHits(res.hits), 2, 'matches both documents');
317-
t.equal(res.hits.hits[0]._score, res.hits.hits[1]._score, 'scores match');
314+
}, (err, { body }) => {
315+
t.false(err);
316+
t.equal(getTotalHits(body.hits), 2, 'matches both documents');
317+
t.equal(body.hits.hits[0]._score, body.hits.hits[1]._score, 'scores match');
318318
done();
319319
});
320320
});

integration/admin_matching.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ module.exports.tests.functional = function(test, common){
4646
suite.client.search({
4747
index: suite.props.index,
4848
body: { query: { match: { 'parent.country': 'Test Country' } } }
49-
}, function( err, res ){
50-
t.equal( err, undefined );
51-
t.equal( getTotalHits(res.hits), 1, 'document found' );
49+
}, (err, { body }) => {
50+
t.false(err);
51+
t.equal( getTotalHits(body.hits), 1, 'document found' );
5252
done();
5353
});
5454
});
@@ -58,9 +58,9 @@ module.exports.tests.functional = function(test, common){
5858
suite.client.search({
5959
index: suite.props.index,
6060
body: { query: { match: { 'parent.country_a': 'TestCountry' } } }
61-
}, function( err, res ){
62-
t.equal( err, undefined );
63-
t.equal( getTotalHits(res.hits), 1, 'document found' );
61+
}, (err, { body }) => {
62+
t.false(err);
63+
t.equal( getTotalHits(body.hits), 1, 'document found' );
6464
done();
6565
});
6666
});
@@ -70,9 +70,9 @@ module.exports.tests.functional = function(test, common){
7070
suite.client.search({
7171
index: suite.props.index,
7272
body: { query: { match: { 'parent.country_id': '100' } } }
73-
}, function( err, res ){
74-
t.equal( err, undefined );
75-
t.equal( getTotalHits(res.hits), 1, 'document found' );
73+
}, (err, { body }) => {
74+
t.false(err);
75+
t.equal( getTotalHits(body.hits), 1, 'document found' );
7676
done();
7777
});
7878
});

integration/analyzer_peliasPhrase.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ module.exports.tests.slop_query = function(test, common){
215215
suite.assert( function( done ){
216216
suite.client.search({
217217
index: suite.props.index,
218-
type: config.schema.typeName,
219218
searchType: 'dfs_query_then_fetch',
220219
body: buildQuery('Lake Cayuga')
221-
}, function( err, res ){
222-
t.equal( getTotalHits(res.hits), 3 );
223-
var hits = res.hits.hits;
220+
}, (err, { body }) => {
221+
t.false(err);
222+
t.equal( getTotalHits(body.hits), 3 );
223+
var hits = body.hits.hits;
224224

225225
t.equal( hits[0]._source.name.default, 'Lake Cayuga' );
226226

@@ -273,9 +273,9 @@ module.exports.tests.slop = function(test, common){
273273
'slop': 3,
274274
}
275275
}}}
276-
}, function( err, res ){
277-
t.equal( err, undefined );
278-
t.equal( getTotalHits(res.hits), 1, 'document found' );
276+
}, (err, { body }) => {
277+
t.false(err);
278+
t.equal( getTotalHits(body.hits), 1, 'document found' );
279279
done();
280280
});
281281
});

integration/autocomplete_abbreviated_street_names.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
3636
'query': 'Grolmanstr.'
3737
}
3838
}}}
39-
}, function( err, res ){
40-
t.equal( err, undefined );
41-
t.equal( getTotalHits(res.hits), 1, 'document found' );
39+
}, (err, { body }) => {
40+
t.false(err);
41+
t.equal( getTotalHits(body.hits), 1, 'document found' );
4242
done();
4343
});
4444
});
@@ -78,9 +78,9 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
7878
// 'query': 'Grolmanstraße'
7979
// }
8080
// }}}
81-
// }, function( err, res ){
82-
// t.equal( err, undefined );
83-
// t.equal( getTotalHits(res.hits), 1, 'document found' );
81+
// }, (err, { body }) => {
82+
// t.false(err);
83+
// t.equal( getTotalHits(body.hits), 1, 'document found' );
8484
// done();
8585
// });
8686
// });
@@ -98,9 +98,9 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
9898
// 'query': 'Grolmanstraße'
9999
// }
100100
// }}}
101-
// }, function( err, res ){
102-
// t.equal( err, undefined );
103-
// t.equal( getTotalHits(res.hits), 1, 'document found' );
101+
// }, (err, { body }) => {
102+
// t.false(err);
103+
// t.equal( getTotalHits(body.hits), 1, 'document found' );
104104
// done();
105105
// });
106106
// });

0 commit comments

Comments
 (0)