Skip to content

Commit

Permalink
SPRXCLT-12: cleaner error handling in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Monjalet committed Aug 7, 2023
1 parent e0c6a12 commit 21cc57b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/unit/sproxyd.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function checkKeyContent(client, key, body, reqUid, callback) {
client.get(key, undefined, reqUid, (err, stream) => {
const chunks = []
if (err) {
done(err);
callback(err);
return;
} else {
stream.on('data', val => {
chunks.push(val);
Expand Down Expand Up @@ -326,15 +327,15 @@ const clientImmutableWithFailover = new Sproxy({
client.put(upStream, upload.length, parameters, reqUid,
(err, key) => {
if (err) {
done(err);
next(err);
return;
}
savedKey = key;
next();
});
},
_ => checkKeyContent(client, savedKey, upload, reqUid, done),
]);
next => checkKeyContent(client, savedKey, upload, reqUid, next),
], done);
});

it('should be able to put more data to sproxyd using the same socket', done => {
Expand All @@ -353,15 +354,15 @@ const clientImmutableWithFailover = new Sproxy({
async.series([
next => client.put(upStream1, upload.length, parameters, reqUid, (err, key) => {
if (err) {
done(err);
next(err);
return;
}
savedKey1 = key;
next();
}),
next => client.put(upStream2, upload.length, parameters, reqUid, (err, key) => {
if (err) {
done(err);
next(err);
return;
}
savedKey2 = key;
Expand All @@ -370,8 +371,8 @@ const clientImmutableWithFailover = new Sproxy({
// Get data for the first key and assert that it matches the original upload
next => checkKeyContent(client, savedKey1, upload, reqUid, next),
// Get data for the second key and assert that it matches the original upload
_ => checkKeyContent(client, savedKey2, upload, reqUid, done),
]);
next => checkKeyContent(client, savedKey2, upload, reqUid, next),
], done);
});
});
});
Expand Down

0 comments on commit 21cc57b

Please sign in to comment.