Permalink
Browse files

test: Make the Go test Windows-compatible

  • Loading branch information...
honzajavorek committed Nov 30, 2017
1 parent b42c79e commit b8f919739ab085e5a2355cfc07518a9424bd3634
Showing with 12 additions and 10 deletions.
  1. +10 −9 test/unit/get-go-bin-test.coffee
  2. +2 −1 test/unit/hooks-worker-client-test.coffee
@@ -1,5 +1,6 @@
{assert} = require('chai')
sinon = require('sinon')
path = require('path')
childProcess = require('child_process')
getGoBin = require('../../src/get-go-bin')
@@ -24,48 +25,48 @@ describe('getGoBin()', ->
callbackArgs = undefined
beforeEach((done) ->
process.env.GOBIN = '/dummy/gobin/path'
process.env.GOBIN = path.join('dummy', 'gobin', 'path')
getGoBin((args...) ->
callbackArgs = args
done()
)
)
it('resolves as $GOBIN', ->
assert.deepEqual(callbackArgs, [null, '/dummy/gobin/path'])
assert.deepEqual(callbackArgs, [null, path.join('dummy', 'gobin', 'path')])
)
)
describe('when $GOPATH is set', ->
callbackArgs = undefined
beforeEach((done) ->
process.env.GOPATH = '/dummy/gopath/path'
process.env.GOPATH = path.join('dummy', 'gopath', 'path')
getGoBin((args...) ->
callbackArgs = args
done()
)
)
it('resolves as $GOPATH + /bin', ->
assert.deepEqual(callbackArgs, [null, '/dummy/gopath/path/bin'])
assert.deepEqual(callbackArgs, [null, path.join('dummy', 'gopath', 'path', 'bin')])
)
)
describe('when both $GOBIN and $GOPATH are set', ->
callbackArgs = undefined
beforeEach((done) ->
process.env.GOBIN = '/dummy/gobin/path'
process.env.GOPATH = '/dummy/gopath/path'
process.env.GOBIN = path.join('dummy', 'gobin', 'path')
process.env.GOPATH = path.join('dummy', 'gopath', 'path')
getGoBin((args...) ->
callbackArgs = args
done()
)
)
it('resolves as $GOBIN', ->
assert.deepEqual(callbackArgs, [null, '/dummy/gobin/path'])
assert.deepEqual(callbackArgs, [null, path.join('dummy', 'gobin', 'path')])
)
)
@@ -74,7 +75,7 @@ describe('getGoBin()', ->
beforeEach((done) ->
sinon.stub(childProcess, 'exec').callsFake((command, callback) ->
callback(null, '/dummy/gopath/path')
callback(null, path.join('dummy', 'gopath', 'path'))
)
getGoBin((args...) ->
callbackArgs = args
@@ -86,7 +87,7 @@ describe('getGoBin()', ->
)
it('calls \'go env GOPATH\' + /bin', ->
assert.deepEqual(callbackArgs, [null, '/dummy/gopath/path/bin'])
assert.deepEqual(callbackArgs, [null, path.join('dummy', 'gopath', 'path', 'bin')])
)
)
@@ -372,12 +372,13 @@ describe 'Hooks worker client', ->
done()
describe 'when --language=go option is given and the worker is installed', ->
dummyPath = path.join('dummy', 'gobin', 'path')
goBin = undefined
goPath = undefined
beforeEach ->
goBin = process.env.GOBIN
goPath = process.env.GOPATH
process.env.GOBIN = '/dummy/gobin/path'
process.env.GOBIN = dummyPath
delete process.env.GOPATH
sinon.stub(crossSpawnStub, 'spawn').callsFake( ->

0 comments on commit b8f9197

Please sign in to comment.