Skip to content

Commit 94261db

Browse files
committed
fixup! Refactor: pass scanId as parameter instead of instance field and fix metric timing
fix(tests): update tests to reflect messageId removal and scanId parameter changes
1 parent e909f9e commit 94261db

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/unit/lifecycle/LifecycleConductor.spec.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,22 @@ describe('Lifecycle Conductor', () => {
237237
getData: (_, cb) => cb(null, null, null),
238238
setData: (path, data, version, cb) => cb(null, { version: 1 }),
239239
};
240+
conductor._producer = { send: (msg, cb) => cb(null, {}) };
240241

241242
sinon.stub(conductor, '_controlBacklog').callsFake(cb => cb(null));
243+
sinon.stub(conductor, 'listBuckets')
244+
.callsFake((queue, scanId, log, cb) => {
245+
// Verify scanId is a valid UUID
246+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
247+
assert(uuidRegex.test(scanId),
248+
`conductorScanId should be a valid UUID v4, got: ${scanId}`);
249+
cb(null, 0);
250+
});
242251
const metricStub = sinon.stub(LifecycleMetrics, 'onConductorFullScan');
243252

244253
conductor.processBuckets(err => {
245254
assert.ifError(err);
246255
assert(metricStub.calledOnce);
247-
const scanId = metricStub.firstCall.args[0];
248-
assert(scanId);
249-
assert(typeof scanId === 'string');
250-
// Validate UUID v4 format: 8-4-4-4-12 hex characters
251-
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
252-
assert(uuidRegex.test(scanId),
253-
`conductorScanId should be a valid UUID v4, got: ${scanId}`);
254256
done();
255257
});
256258
});

0 commit comments

Comments
 (0)