From 636ecd62d06c20db5b7a0406a5ce69df2ca7f6bc Mon Sep 17 00:00:00 2001 From: Lee Harold Date: Mon, 2 Jul 2018 12:17:39 -0500 Subject: [PATCH 1/2] change getSocketPath test to handle different socket path format when run on Windows --- __tests__/unit.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/__tests__/unit.js b/__tests__/unit.js index d5e960af..42b18f84 100644 --- a/__tests__/unit.js +++ b/__tests__/unit.js @@ -92,7 +92,13 @@ test('mapApiGatewayEventToHttpRequest: without headers', () => { test('getSocketPath', () => { const socketPath = awsServerlessExpress.getSocketPath('12345abcdef') - expect(socketPath).toEqual('/tmp/server-12345abcdef.sock') + var isWin = process.platform === 'win32' + if (isWin) { + const last = socketPath.split('\\').slice(-1)[0] + expect(last).toEqual('server-12345abcdef') + } else { + expect(socketPath).toEqual('/tmp/server-12345abcdef.sock') + } }) const PassThrough = require('stream').PassThrough From f51d60a380bf938c2ea125554b803f46d85c7cab Mon Sep 17 00:00:00 2001 From: Lee Harold Date: Mon, 2 Jul 2018 15:16:28 -0500 Subject: [PATCH 2/2] refactor: test based on feedback --- __tests__/unit.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/__tests__/unit.js b/__tests__/unit.js index 42b18f84..14d909c9 100644 --- a/__tests__/unit.js +++ b/__tests__/unit.js @@ -1,4 +1,7 @@ 'use strict' + +const path = require('path') + const awsServerlessExpress = require('../src/index') test('getPathWithQueryStringParams: no params', () => { @@ -92,13 +95,9 @@ test('mapApiGatewayEventToHttpRequest: without headers', () => { test('getSocketPath', () => { const socketPath = awsServerlessExpress.getSocketPath('12345abcdef') - var isWin = process.platform === 'win32' - if (isWin) { - const last = socketPath.split('\\').slice(-1)[0] - expect(last).toEqual('server-12345abcdef') - } else { - expect(socketPath).toEqual('/tmp/server-12345abcdef.sock') - } + const isWin = process.platform === 'win32' + const expectedSocketPath = isWin ? path.join('\\\\?\\\\pipe\\\\', process.cwd(), 'server-12345abcdef') : '/tmp/server-12345abcdef.sock' + expect(socketPath).toBe(expectedSocketPath) }) const PassThrough = require('stream').PassThrough