Skip to content

Commit

Permalink
Fix - Wasstarting mock server when testing real device
Browse files Browse the repository at this point in the history
the enviroment vars HOSTNAME, PORT, USERNAME, PASSWORD are used to point
the mocha tests at a real device.
However bugs had snuck in and when testing with a real device we were still starting the
Mock Server.
So, only start the MockServer when there is no HOSTNAME et.
Also required mocha to be bumped for the mocha.opts file and --exclude
so mocha did not try and test (and run) the mockserver.
I just chose mocha 6, no real reason other than I know it has --exclude in mocha.opts
  • Loading branch information
RogerHardiman committed Apr 3, 2021
1 parent 6a3afb9 commit 9a56edc
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"eslint": "^5.5.0",
"eslint-plugin-node": "^7.0.1",
"keypress": "^0.2.1",
"mocha": "^2.1.0",
"mocha": "^6.0.0",
"mocha-lcov-reporter": "0.0.1",
"nimble": "^0.0.2",
"nyc": "^14.1.1",
Expand Down
1 change: 1 addition & 0 deletions test/device.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
synthTest = not process.env.HOSTNAME

assert = require 'assert'
onvif = require('../lib/onvif')
serverMockup = require('./serverMockup') if synthTest
Expand Down
4 changes: 3 additions & 1 deletion test/discovery.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
synthTest = not process.env.HOSTNAME

assert = require 'assert'
onvif = require('../lib/onvif')
serverMockup = require('./serverMockup')
serverMockup = require('./serverMockup') if synthTest

describe 'Discovery', () ->
this.timeout 10000
Expand Down
6 changes: 4 additions & 2 deletions test/events.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
synthTest = not process.env.HOSTNAME

assert = require 'assert'
onvif = require('../lib/onvif')
serverMockup = require('./serverMockup')
serverMockup = require('./serverMockup') if synthTest

describe 'Events', () ->
cam = null
Expand Down Expand Up @@ -67,4 +69,4 @@ describe 'Events', () ->
setTimeout () ->
assert.ok cam.events.terminationTime is undefined
done()
, 1000
, 1000
6 changes: 4 additions & 2 deletions test/imaging.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
synthTest = not process.env.HOSTNAME

assert = require 'assert'
onvif = require('../lib/onvif')
serverMockup = require('./serverMockup')
serverMockup = require('./serverMockup') if synthTest
util = require('util')

describe 'Imaging', () ->
Expand Down Expand Up @@ -65,4 +67,4 @@ describe 'Imaging', () ->
assert.equal err, null
['token', 'type', 'Name'].every (prop) ->
res[prop]
done()
done()
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--exclude serverMockup.js
11 changes: 7 additions & 4 deletions test/zzzterminate.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
serverMockup = require('./serverMockup')
synthTest = not process.env.HOSTNAME

serverMockup = require('./serverMockup') if synthTest

describe 'Terminating', () ->
it 'should terminate serverMockup', (done) ->
serverMockup.close()
done()
if synthTest
it 'should terminate serverMockup', (done) ->
serverMockup.close()
done()

0 comments on commit 9a56edc

Please sign in to comment.