Implement os module

This commit is contained in:
Juan Cruz Viotti 2014-12-02 11:28:49 -04:00
parent ccf92411fe
commit b89524c43b
3 changed files with 44 additions and 0 deletions

View File

@ -9,4 +9,5 @@ module.exports =
device: require('./device/device')
ui: require('./ui')
cli: require('./cli/cli')
os: require('./os/os')
config: require('./config')

7
lib/resin/os/os.coffee Normal file
View File

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

View File

@ -0,0 +1,36 @@
_ = require('lodash')
chai = require('chai')
expect = chai.expect
os = require('./os')
APPS =
validEthernet:
id: 91
params:
network: 'ethernet'
invalidNetworkType:
id: 91
params:
network: 'foobar'
validWifi:
id: 91
params:
network: 'wifi'
wifiSsid: 'MYSSID'
describe 'OS:', ->
describe '#generateCacheName()', ->
describe 'given network is ethernet', ->
it 'should construct a correct name', ->
application = APPS.validEthernet
result = os.generateCacheName(application.id, application.params)
expect(result).to.equal("#{application.id}-ethernet-#{Date.now()}")
describe 'given network is wifi', ->
it 'should construct a correct name', ->
application = APPS.validWifi
result = os.generateCacheName(application.id, application.params)
expect(result).to.equal("#{application.id}-wifi-#{application.params.wifiSsid}-#{Date.now()}")