Get rid of cache module

This commit is contained in:
Juan Cruz Viotti 2015-01-09 13:41:32 -03:00
parent 2b5c1a664e
commit 5a3254dc5e
3 changed files with 2 additions and 44 deletions

View File

@ -7,7 +7,6 @@ resin = require('resin-sdk')
log = require('../log/log')
permissions = require('../permissions/permissions')
errors = require('../errors/errors')
cache = require('../cache/cache')
exports.download = (params, options) ->
@ -20,10 +19,7 @@ exports.download = (params, options) ->
wifiKey: options.key
appId: params.id
# TODO: Change cache.generateCacheName to accept a ConnectionParams instance
# to avoid the complication of having to omit it from the object and pass
# as another parameter
fileName = cache.generateCacheName(params.id, _.omit(connectionParams, 'appId'))
fileName = resin.models.os.generateCacheName(connectionParams)
outputFile = options.output or path.join(resin.settings.get('directories.os'), fileName)
@ -36,6 +32,7 @@ exports.download = (params, options) ->
return callback(error)
(callback) ->
log.info("Destination file: #{outputFile}")
bar = null
received = 0

View File

@ -1,7 +0,0 @@
exports.generateCacheName = (id, connectionParams) ->
result = "#{id}-#{connectionParams.network}"
if connectionParams.wifiSsid?
result += "-#{connectionParams.wifiSsid}"
return "#{result}-#{Date.now()}"

View File

@ -1,32 +0,0 @@
_ = require('lodash')
sinon = require('sinon')
chai = require('chai')
chai.use(require('chai-string'))
expect = chai.expect
cache = require('./cache')
describe 'Cache:', ->
describe '#generateCacheName()', ->
describe 'given network is ethernet', ->
it 'should construct a correct name', ->
application =
id: 91
params:
network: 'ethernet'
result = cache.generateCacheName(application.id, application.params)
expect(result).to.match(new RegExp("#{application.id}-ethernet-\\d\+\$"))
describe 'given network is wifi', ->
it 'should construct a correct name', ->
application =
id: 91
params:
network: 'wifi'
wifiSsid: 'MYSSID'
result = cache.generateCacheName(application.id, application.params)
expect(result).to.match(new RegExp("#{application.id}-wifi-#{application.params.wifiSsid}-\\d\+\$"))