Skip to content

Commit b44e631

Browse files
added size tests
1 parent 65c7ffe commit b44e631

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/unit/cmap/connect.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ describe('Connect Tests', function () {
216216
const handshakeDocument = await prepareHandshakeDocument(authContext);
217217
expect(handshakeDocument.client.env).to.not.have.property('name');
218218
});
219+
220+
context('when 512 byte size limit is exceeded', async () => {
221+
it(`should not 'env' property in client`, async () => {
222+
let longAppName = '';
223+
// make metadata = 507 bytes, so it takes up entire LimitedSizeDocument
224+
for (let i = 0; i < 493; i++) {
225+
longAppName += 's';
226+
}
227+
const longAuthContext = {
228+
connection: {},
229+
options: { ...CONNECT_DEFAULTS, metadata: { appName: longAppName } }
230+
};
231+
const handshakeDocument = await prepareHandshakeDocument(longAuthContext);
232+
expect(handshakeDocument.client).to.not.have.property('env');
233+
});
234+
});
219235
});
220236

221237
context('when kubernetes and FAAS are both present', () => {
@@ -245,6 +261,28 @@ describe('Connect Tests', function () {
245261
const handshakeDocument = await prepareHandshakeDocument(authContext);
246262
expect(handshakeDocument.client.env.name).to.equal('aws.lambda');
247263
});
264+
265+
context('when 512 byte size limit is exceeded', async () => {
266+
it(`should not have 'container' property in client.env`, async () => {
267+
let longAppName = '';
268+
// make metadata = 507 bytes, so it takes up entire LimitedSizeDocument
269+
for (let i = 0; i < 485; i++) {
270+
longAppName += 's';
271+
}
272+
const longAuthContext = {
273+
connection: {},
274+
options: {
275+
...CONNECT_DEFAULTS,
276+
metadata: {
277+
appName: longAppName,
278+
env: { name: 'aws.lambda' }
279+
}
280+
}
281+
};
282+
const handshakeDocument = await prepareHandshakeDocument(longAuthContext);
283+
expect(handshakeDocument.client).to.not.have.property('env');
284+
});
285+
});
248286
});
249287

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

0 commit comments

Comments
 (0)