Skip to content

Commit

Permalink
test: Fix tests for environments with Go
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Nov 30, 2017
1 parent 40a8388 commit b1249de
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions test/unit/hooks-worker-client-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sinon = require 'sinon'
net = require 'net'
{assert} = require 'chai'
clone = require 'clone'
childProcess = require('child_process')

crossSpawnStub = require('cross-spawn')
whichStub = require('../../src/which')
Expand Down Expand Up @@ -344,24 +345,15 @@ describe 'Hooks worker client', ->
assert.include err.message, "composer require ddelnano/dredd-hooks-php --dev"
done()

describe 'when --language=go option is given and go is not installed', ->
beforeEach ->
runner.hooks['configuration'] =
options:
language: 'go'
hookfiles: 'gobinary'

it 'should write an error', (done) ->
loadWorkerClient (err) ->
assert.isOk err
assert.include err.message, "Go doesn't seem to be installed"
done()

describe 'when --language=go option is given and the worker is not installed', ->
goBin = undefined
goPath = undefined
beforeEach ->
goBin = process.env.GOBIN
goPath = process.env.GOPATH
process.env.GOBIN = '/dummy/gobin/path'
delete process.env.GOPATH

sinon.stub(whichStub, 'which').callsFake (command) -> false

runner.hooks['configuration'] =
Expand All @@ -371,6 +363,7 @@ describe 'Hooks worker client', ->
afterEach ->
whichStub.which.restore()
process.env.GOBIN = goBin
process.env.GOPATH = goPath

it 'should write a hint how to install', (done) ->
loadWorkerClient (err) ->
Expand All @@ -380,9 +373,13 @@ describe 'Hooks worker client', ->

describe 'when --language=go option is given and the worker is installed', ->
goBin = undefined
goPath = undefined
beforeEach ->
goBin = process.env.GOBIN
goPath = process.env.GOPATH
process.env.GOBIN = '/dummy/gobin/path'
delete process.env.GOPATH

sinon.stub(crossSpawnStub, 'spawn').callsFake( ->
emitter = new EventEmitter
emitter.stdout = new EventEmitter
Expand All @@ -408,6 +405,7 @@ describe 'Hooks worker client', ->
whichStub.which.restore()
HooksWorkerClient.prototype.terminateHandler.restore()
process.env.GOBIN = goBin
process.env.GOPATH = goPath

it 'should spawn the server process with command "$GOBIN/goodman"', (done) ->
loadWorkerClient (err) ->
Expand Down

0 comments on commit b1249de

Please sign in to comment.