Skip to content

Commit

Permalink
added size tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Mar 4, 2024
1 parent 65c7ffe commit b44e631
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/unit/cmap/connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ describe('Connect Tests', function () {
const handshakeDocument = await prepareHandshakeDocument(authContext);
expect(handshakeDocument.client.env).to.not.have.property('name');
});

context('when 512 byte size limit is exceeded', async () => {
it(`should not 'env' property in client`, async () => {
let longAppName = '';
// make metadata = 507 bytes, so it takes up entire LimitedSizeDocument
for (let i = 0; i < 493; i++) {
longAppName += 's';
}
const longAuthContext = {
connection: {},
options: { ...CONNECT_DEFAULTS, metadata: { appName: longAppName } }
};
const handshakeDocument = await prepareHandshakeDocument(longAuthContext);
expect(handshakeDocument.client).to.not.have.property('env');
});
});
});

context('when kubernetes and FAAS are both present', () => {
Expand Down Expand Up @@ -245,6 +261,28 @@ describe('Connect Tests', function () {
const handshakeDocument = await prepareHandshakeDocument(authContext);
expect(handshakeDocument.client.env.name).to.equal('aws.lambda');
});

context('when 512 byte size limit is exceeded', async () => {
it(`should not have 'container' property in client.env`, async () => {
let longAppName = '';
// make metadata = 507 bytes, so it takes up entire LimitedSizeDocument
for (let i = 0; i < 485; i++) {
longAppName += 's';
}
const longAuthContext = {
connection: {},
options: {
...CONNECT_DEFAULTS,
metadata: {
appName: longAppName,
env: { name: 'aws.lambda' }
}
}
};
const handshakeDocument = await prepareHandshakeDocument(longAuthContext);
expect(handshakeDocument.client).to.not.have.property('env');
});
});
});

context('when container nor FAAS env is not present (empty string case)', () => {
Expand Down

0 comments on commit b44e631

Please sign in to comment.