From a391987c40500b00d4302cda1d2d7c39e2cc46af Mon Sep 17 00:00:00 2001 From: Rob Rudin Date: Thu, 30 Oct 2025 11:15:11 -0400 Subject: [PATCH] MLE-24976 Couple of Polaris fixes in tests --- test-complete/nodejs-dmsdk-queryToTransformAll.js | 14 ++++++++------ test-complete/nodejs-documents-read-chunk.js | 11 ++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/test-complete/nodejs-dmsdk-queryToTransformAll.js b/test-complete/nodejs-dmsdk-queryToTransformAll.js index a348f704..d35e8e30 100644 --- a/test-complete/nodejs-dmsdk-queryToTransformAll.js +++ b/test-complete/nodejs-dmsdk-queryToTransformAll.js @@ -21,7 +21,7 @@ const query = q.where(ctsQb.cts.directoryQuery('/test/dataMovement/requests/tran describe('data movement transformAll - nodejs-dmsdk-queryToTransformAll', function () { before(async function () { - await restAdminDB.config.transforms.write(transformName, 'javascript', + await restAdminDB.config.transforms.write(transformName, 'javascript', fs.createReadStream(transformPath)).result(); for (let i = 0; i < 100; i++) { uris.push('/test/dataMovement/requests/transformAll/' + i + '.json'); @@ -164,7 +164,7 @@ describe('data movement transformAll - nodejs-dmsdk-queryToTransformAll', functi } }); }); - + summary.docsTransformedSuccessfully.should.be.equal(100); summary.docsFailedToBeTransformed.should.be.equal(0); summary.timeElapsed.should.be.greaterThanOrEqual(0); @@ -195,12 +195,12 @@ describe('data movement transformAll - nodejs-dmsdk-queryToTransformAll', functi summary.docsTransformedSuccessfully.should.be.equal(100); summary.docsFailedToBeTransformed.should.be.equal(0); summary.timeElapsed.should.be.greaterThanOrEqual(0); - + await verifyDocs('transformedValue'); }); it('should queryToTransformAll documents with onCompletion option', async function () { - const summary = await new Promise((resolve, reject) => { + const summary = await new Promise((resolve, reject) => { dbWriter.documents.queryToTransformAll(query, { transform: [transformName, { newValue: 'transformedValue' }], onCompletion: ((summary) => { @@ -220,7 +220,7 @@ describe('data movement transformAll - nodejs-dmsdk-queryToTransformAll', functi }); it('should work with batchSize less than 1', async function () { - const summary = await new Promise((resolve, reject) => { + const summary = await new Promise((resolve, reject) => { dbWriter.documents.queryToTransformAll(query, { transform: [transformName, { newValue: 'transformedValue' }], batchSize: 0, @@ -296,8 +296,10 @@ describe('data movement transformAll - nodejs-dmsdk-queryToTransformAll', functi async function verifyDocs(value) { const documents = await dbWriter.documents.read(uris).result(); + should.exist(documents); + documents.should.be.an.Array(); documents.length.should.equal(100); for (let i = 0; i < documents.length; i++) { documents[i].content.key.should.equal(value); } -} \ No newline at end of file +} diff --git a/test-complete/nodejs-documents-read-chunk.js b/test-complete/nodejs-documents-read-chunk.js index 8855de11..7dd0024b 100644 --- a/test-complete/nodejs-documents-read-chunk.js +++ b/test-complete/nodejs-documents-read-chunk.js @@ -21,7 +21,7 @@ const dbAdmin = marklogic.createDatabaseClient(testconfig.restAdminConnection); describe('Binary documents test', function () { const binaryPath = __dirname + '/data/somePdfFile.pdf'; let binaryValue = null; - + const uri = '/test/binary/somePdfFile.pdf'; before(async function () { @@ -46,27 +46,28 @@ describe('Binary documents test', function () { content: readableBinary }).result(); + should.exist(response); response.should.have.property('documents'); const streamData = await new Promise((resolve, reject) => { const chunks = []; const readStream = dbReader.documents.read(uri).stream('chunked'); - + readStream.on('data', function (data) { chunks.push(data); }); - + readStream.on('end', function () { resolve(Buffer.concat(chunks)); }); - + readStream.on('error', function (error) { reject(error); }); }); Buffer.compare(binaryValue, streamData).should.equal(0); - + // Verify the binary content has a string near the end of the file const strData = streamData.toString(); strData.should.containEql('CVISION Technologies');