Skip to content

Commit

Permalink
test: Make the Go test Windows-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Nov 30, 2017
1 parent b42c79e commit b8f9197
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
19 changes: 10 additions & 9 deletions test/unit/get-go-bin-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')
Expand All @@ -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')])
)
)

Expand All @@ -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
Expand All @@ -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')])
)
)

Expand Down
3 changes: 2 additions & 1 deletion test/unit/hooks-worker-client-test.coffee
Expand Up @@ -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( ->
Expand Down

0 comments on commit b8f9197

Please sign in to comment.