Skip to content

Commit 21cc57b

Browse files
author
Florent Monjalet
committed
SPRXCLT-12: cleaner error handling in tests
1 parent e0c6a12 commit 21cc57b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests/unit/sproxyd.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function checkKeyContent(client, key, body, reqUid, callback) {
5858
client.get(key, undefined, reqUid, (err, stream) => {
5959
const chunks = []
6060
if (err) {
61-
done(err);
61+
callback(err);
62+
return;
6263
} else {
6364
stream.on('data', val => {
6465
chunks.push(val);
@@ -326,15 +327,15 @@ const clientImmutableWithFailover = new Sproxy({
326327
client.put(upStream, upload.length, parameters, reqUid,
327328
(err, key) => {
328329
if (err) {
329-
done(err);
330+
next(err);
330331
return;
331332
}
332333
savedKey = key;
333334
next();
334335
});
335336
},
336-
_ => checkKeyContent(client, savedKey, upload, reqUid, done),
337-
]);
337+
next => checkKeyContent(client, savedKey, upload, reqUid, next),
338+
], done);
338339
});
339340

340341
it('should be able to put more data to sproxyd using the same socket', done => {
@@ -353,15 +354,15 @@ const clientImmutableWithFailover = new Sproxy({
353354
async.series([
354355
next => client.put(upStream1, upload.length, parameters, reqUid, (err, key) => {
355356
if (err) {
356-
done(err);
357+
next(err);
357358
return;
358359
}
359360
savedKey1 = key;
360361
next();
361362
}),
362363
next => client.put(upStream2, upload.length, parameters, reqUid, (err, key) => {
363364
if (err) {
364-
done(err);
365+
next(err);
365366
return;
366367
}
367368
savedKey2 = key;
@@ -370,8 +371,8 @@ const clientImmutableWithFailover = new Sproxy({
370371
// Get data for the first key and assert that it matches the original upload
371372
next => checkKeyContent(client, savedKey1, upload, reqUid, next),
372373
// Get data for the second key and assert that it matches the original upload
373-
_ => checkKeyContent(client, savedKey2, upload, reqUid, done),
374-
]);
374+
next => checkKeyContent(client, savedKey2, upload, reqUid, next),
375+
], done);
375376
});
376377
});
377378
});

0 commit comments

Comments
 (0)