Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions test-complete/nodejs-dmsdk-queryToTransformAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) => {
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct assertion syntax is documents.should.be.an('array') (lowercase string) or documents.should.be.an.instanceOf(Array). The current syntax documents.should.be.an.Array() is incorrect and will likely fail.

Suggested change
documents.should.be.an.Array();
documents.should.be.an('array');

Copilot uses AI. Check for mistakes.
documents.length.should.equal(100);
for (let i = 0; i < documents.length; i++) {
documents[i].content.key.should.equal(value);
}
}
}
11 changes: 6 additions & 5 deletions test-complete/nodejs-documents-read-chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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');
Expand Down