Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-3998): metadata duplication in handshake #3615

Merged
merged 12 commits into from
Mar 31, 2023
Prev Previous commit
Next Next commit
beef up tests
baileympearson committed Mar 31, 2023

Verified

This commit was signed with the committer’s verified signature.
MindTooth Birger Johan Nordølum
commit a9adccff8a2b2d46a2fea26eb1c6dc783958c223
50 changes: 41 additions & 9 deletions test/unit/cmap/handshake/client_metadata.test.ts
Original file line number Diff line number Diff line change
@@ -13,31 +13,63 @@ describe('makeClientMetadata()', () => {
driverInfo: { platform: 'myPlatform' }
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved
};
const metadata = makeClientMetadata(options);
expect(metadata).to.have.property(
'platform',
`Node.js ${process.version}, ${os.endianness()}|myPlatform`
);
expect(metadata).to.deep.equal({
driver: {
name: 'nodejs',
version: NODE_DRIVER_VERSION
},
os: {
type: os.type(),
name: process.platform,
architecture: process.arch,
version: os.release()
},
platform: `Node.js ${process.version}, ${os.endianness()}|myPlatform`
});
});
});

context('when driverInfo.name is provided', () => {
it('appends driverInfo.name to the driver.name field', () => {
const options = {
driverInfo: { name: 'myName' }
};
const metadata = makeClientMetadata(options);
expect(metadata).to.have.nested.property('driver.name', `nodejs|myName`);
expect(metadata).to.deep.equal({
driver: {
name: 'nodejs|myName',
version: NODE_DRIVER_VERSION
},
os: {
type: os.type(),
name: process.platform,
architecture: process.arch,
version: os.release()
},
platform: `Node.js ${process.version}, ${os.endianness()}`
});
});
});

context('when driverInfo.version is provided', () => {
it('appends driverInfo.version to the version field', () => {
const options = {
driverInfo: { version: 'myVersion' }
};
const metadata = makeClientMetadata(options);
expect(metadata).to.have.nested.property(
'driver.version',
`${NODE_DRIVER_VERSION}|myVersion`
);
expect(metadata).to.deep.equal({
driver: {
name: 'nodejs',
version: `${NODE_DRIVER_VERSION}|myVersion`
},
os: {
type: os.type(),
name: process.platform,
architecture: process.arch,
version: os.release()
},
platform: `Node.js ${process.version}, ${os.endianness()}`
});
});
});