Skip to content

Commit

Permalink
Mark the callback as optional
Browse files Browse the repository at this point in the history
Without callback, it is impossible to unit-test the backbeat
routes, as we run async code and do not yet support promises.

Issue: CLDSRV-591
  • Loading branch information
williamlardier committed Dec 10, 2024
1 parent a0f2c3f commit 86b0544
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/routes/routeBackbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,8 @@ const indexingSchema = joi.array().items(indexEntrySchema).min(1);

function respondToRequest(err, response, log, callback) {
responseJSONBody(err, null, response, log);
return callback(err);
// The callback is optional, as it is only used for testing purposes
return callback?.(err);
}

function routeIndexingAPIs(request, response, userInfo, log, callback) {
Expand Down
5 changes: 0 additions & 5 deletions tests/unit/routeBackbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const testBucket = {
namespace,
headers: {
'host': `${bucketName}.s3.amazonaws.com`,
// set versioning

},
url: `/${bucketName}`,
actionImplicitDenies: false,
Expand All @@ -47,7 +45,6 @@ describe('routeBackbeat', () => {
let response;

beforeEach(() => {
// Mock backbeatRoutes
sinon.stub(backbeatRoutes, 'PUT').returns({
data: sinon.stub(),
metadata: sinon.stub(),
Expand Down Expand Up @@ -86,7 +83,6 @@ describe('routeBackbeat', () => {
index: sinon.stub(),
});

// Mock request and response
request = new DummyRequest(
{
method: 'GET',
Expand Down Expand Up @@ -131,7 +127,6 @@ describe('routeBackbeat', () => {
target: `${bucketName}/${objectName}`,
operation: null,
versionId: false,
// not sending any body here, so expect error
expect: errors.MalformedPOSTRequest,
},
{
Expand Down

0 comments on commit 86b0544

Please sign in to comment.