mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 06:07:55 +00:00
32 lines
688 B
CoffeeScript
32 lines
688 B
CoffeeScript
mockFs = require('mock-fs')
|
|
sinon = require('sinon')
|
|
resin = require('../../lib/resin')
|
|
connection = require('../../lib/connection/connection')
|
|
|
|
exports.fs =
|
|
|
|
init: (filesystemConfig = {}) ->
|
|
mockFsOptions = {}
|
|
|
|
# Mock data prefix automatically to remove
|
|
# duplication in most of the tests
|
|
mockFsOptions[resin.settings.get('dataPrefix')] = mockFs.directory()
|
|
|
|
for key, value of filesystemConfig
|
|
mockFsOptions[value.name] = value.contents
|
|
mockFs(mockFsOptions)
|
|
|
|
restore: ->
|
|
mockFs.restore()
|
|
|
|
isOnlineStub = null
|
|
|
|
exports.connection =
|
|
|
|
init: ->
|
|
isOnlineStub = sinon.stub(connection, 'isOnline')
|
|
isOnlineStub.yields(null, true)
|
|
|
|
restore: ->
|
|
isOnlineStub.restore()
|