Skip to content

Conversation

@LCHarold
Copy link
Contributor

@LCHarold LCHarold commented Jul 2, 2018

Added if statement to see if we're running on Windows. If so, then the socket path will look like this:
\\?\pipe\C:\repo\github\aws-serverless-express\server-12345abcdef
rather than:
/tmp/server-12345abcdef.sock

so we just evaluate the last segment from the Windows path.

@brettstack brettstack changed the title change getSocketPath test to handle different socket path format when run on Windows test: fix getSocketPath test for Windows Jul 2, 2018
test('getSocketPath', () => {
const socketPath = awsServerlessExpress.getSocketPath('12345abcdef')
expect(socketPath).toEqual('/tmp/server-12345abcdef.sock')
var isWin = process.platform === 'win32'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this const

expect(socketPath).toEqual('/tmp/server-12345abcdef.sock')
var isWin = process.platform === 'win32'
if (isWin) {
const last = socketPath.split('\\').slice(-1)[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to test the entire socketPath based on process.cwd()

var isWin = process.platform === 'win32'
if (isWin) {
const last = socketPath.split('\\').slice(-1)[0]
expect(last).toEqual('server-12345abcdef')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of if/else, let's do:

const expectedSocketPath = isWin ? .. : ..
expect(socketPath).toBe(expectedSocketPath)

@brettstack
Copy link
Collaborator

Awesome! Thanks for this. I assume this was blocking Windows users from contributing.

Travis build is failing due to commit message which I'll change during merge.

@brettstack brettstack merged commit fca195d into CodeGenieApp:develop Jul 2, 2018
@LCHarold LCHarold deleted the develop branch December 21, 2018 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants