2014-11-14 19:48:37 +00:00
|
|
|
mockFs = require('mock-fs')
|
2014-11-24 18:55:05 +00:00
|
|
|
sinon = require('sinon')
|
2014-11-26 17:42:05 +00:00
|
|
|
resin = require('../../lib/resin')
|
2014-11-24 18:55:05 +00:00
|
|
|
connection = require('../../lib/connection/connection')
|
2014-11-14 19:48:37 +00:00
|
|
|
|
|
|
|
exports.fs =
|
|
|
|
|
|
|
|
init: (filesystemConfig = {}) ->
|
|
|
|
mockFsOptions = {}
|
|
|
|
|
|
|
|
# Mock data prefix automatically to remove
|
|
|
|
# duplication in most of the tests
|
2014-12-05 15:49:00 +00:00
|
|
|
mockFsOptions[resin.settings.get('dataPrefix')] = mockFs.directory()
|
2014-11-14 19:48:37 +00:00
|
|
|
|
|
|
|
for key, value of filesystemConfig
|
|
|
|
mockFsOptions[value.name] = value.contents
|
|
|
|
mockFs(mockFsOptions)
|
|
|
|
|
|
|
|
restore: ->
|
|
|
|
mockFs.restore()
|
2014-11-24 18:55:05 +00:00
|
|
|
|
|
|
|
isOnlineStub = null
|
|
|
|
|
|
|
|
exports.connection =
|
|
|
|
|
|
|
|
init: ->
|
|
|
|
isOnlineStub = sinon.stub(connection, 'isOnline')
|
|
|
|
isOnlineStub.yields(null, true)
|
|
|
|
|
|
|
|
restore: ->
|
|
|
|
isOnlineStub.restore()
|