Skip to content

Commit af165cd

Browse files
added tests - no docker tests
1 parent d43d9fd commit af165cd

File tree

1 file changed

+23
-54
lines changed

1 file changed

+23
-54
lines changed

test/unit/cmap/connect.test.ts

Lines changed: 23 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { expect } from 'chai';
2-
import { promises as fs } from 'fs';
3-
import * as sinon from 'sinon';
42

53
import {
64
CancellationToken,
@@ -29,6 +27,7 @@ const CONNECT_DEFAULTS = {
2927
};
3028

3129
describe('Connect Tests', async function () {
30+
3231
context('when PLAIN auth enabled', () => {
3332
const test: {
3433
server?: any;
@@ -188,6 +187,28 @@ describe('Connect Tests', async function () {
188187
});
189188

190189
context('prepareHandshakeDocument', async () => {
190+
context('when container is present', async () => {
191+
const authContext = {
192+
connection: {},
193+
options: { ...CONNECT_DEFAULTS }
194+
};
195+
196+
context('when only kubernetes is present', async () => {
197+
beforeEach(() => {
198+
process.env.KUBERNETES_SERVICE_HOST = 'I exist';
199+
});
200+
201+
afterEach(() => {
202+
process.env.KUBERNETES_SERVICE_HOST = '';
203+
});
204+
205+
it(`should include { orchestrator: 'kubernetes'} in client.env.container`, async () => {
206+
const handshakeDocument = await prepareHandshakeDocument(authContext);
207+
expect(handshakeDocument.client.env.container.orchestrator).to.equal('kubernetes');
208+
});
209+
});
210+
});
211+
191212
context('when serverApi.version is present', () => {
192213
const options = { ...CONNECT_DEFAULTS };
193214
const authContext = {
@@ -281,57 +302,5 @@ describe('Connect Tests', async function () {
281302
});
282303
});
283304
});
284-
285-
describe('containers', async () => {
286-
const authContext = {
287-
connection: {},
288-
options: { ...CONNECT_DEFAULTS }
289-
};
290-
context('when container is present', async () => {
291-
292-
context('when both kubernetes and docker are present', async () => {
293-
beforeEach(() => {
294-
process.env.KUBERNETES_SERVICE_HOST = 'I exist';
295-
const stub = sinon.stub(fs, 'access');
296-
stub.callsFake(async function () {});
297-
});
298-
afterEach(() => {
299-
process.env.KUBERNETES_SERVICE_HOST = '';
300-
sinon.restore();
301-
});
302-
it('should include both in client.env.container properly', async () => {
303-
const handshakeDocument = await prepareHandshakeDocument(authContext);
304-
expect(handshakeDocument.client.env.container.orchestrator).to.equal('kubernetes');
305-
expect(handshakeDocument.client.env.container.runtime).to.equal('docker');
306-
});
307-
});
308-
context('when only kubernetes is present', async () => {
309-
beforeEach(() => {
310-
process.env.KUBERNETES_SERVICE_HOST = 'I exist';
311-
});
312-
afterEach(() => {
313-
process.env.KUBERNETES_SERVICE_HOST = '';
314-
});
315-
it(`should include { orchestrator: 'kubernetes'} in client.env.container`, async () => {
316-
const handshakeDocument = await prepareHandshakeDocument(authContext);
317-
expect(handshakeDocument.client.env.container.orchestrator).to.equal('kubernetes');
318-
});
319-
});
320-
context('when only docker is present', async () => {
321-
beforeEach(() => {
322-
const stub = sinon.stub(fs, 'access');
323-
stub.callsFake(async function () {});
324-
});
325-
afterEach(() => {
326-
process.env.KUBERNETES_SERVICE_HOST = '';
327-
sinon.restore();
328-
});
329-
it(`should include { runtime: 'docker'} in client.env.container`, async () => {
330-
const handshakeDocument = await prepareHandshakeDocument(authContext);
331-
expect(handshakeDocument.client.env.container.runtime).to.equal('docker');
332-
});
333-
});
334-
});
335-
});
336305
});
337306
});

0 commit comments

Comments
 (0)