balena-cli/tests/utils/mock.coffee
Juan Cruz Viotti 58cc0be0c9 Cleanup tests
2014-11-14 15:48:37 -04:00

19 lines
415 B
CoffeeScript

mockFs = require('mock-fs')
config = require('../../lib/config')
exports.fs =
init: (filesystemConfig = {}) ->
mockFsOptions = {}
# Mock data prefix automatically to remove
# duplication in most of the tests
mockFsOptions[config.dataPrefix] = mockFs.directory()
for key, value of filesystemConfig
mockFsOptions[value.name] = value.contents
mockFs(mockFsOptions)
restore: ->
mockFs.restore()