|
1 | 1 | import { expect } from 'chai';
|
2 |
| -import { promises as fs } from 'fs'; |
3 |
| -import * as sinon from 'sinon'; |
4 | 2 |
|
5 | 3 | import {
|
6 | 4 | CancellationToken,
|
@@ -29,6 +27,7 @@ const CONNECT_DEFAULTS = {
|
29 | 27 | };
|
30 | 28 |
|
31 | 29 | describe('Connect Tests', async function () {
|
| 30 | + |
32 | 31 | context('when PLAIN auth enabled', () => {
|
33 | 32 | const test: {
|
34 | 33 | server?: any;
|
@@ -188,6 +187,28 @@ describe('Connect Tests', async function () {
|
188 | 187 | });
|
189 | 188 |
|
190 | 189 | 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 | + |
191 | 212 | context('when serverApi.version is present', () => {
|
192 | 213 | const options = { ...CONNECT_DEFAULTS };
|
193 | 214 | const authContext = {
|
@@ -281,57 +302,5 @@ describe('Connect Tests', async function () {
|
281 | 302 | });
|
282 | 303 | });
|
283 | 304 | });
|
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 |
| - }); |
336 | 305 | });
|
337 | 306 | });
|
0 commit comments