mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 22:47:48 +00:00
Implement os module
This commit is contained in:
parent
ccf92411fe
commit
b89524c43b
@ -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
7
lib/resin/os/os.coffee
Normal file
@ -0,0 +1,7 @@
|
||||
exports.generateCacheName = (id, connectionParams) ->
|
||||
result = "#{id}-#{connectionParams.network}"
|
||||
|
||||
if connectionParams.wifiSsid?
|
||||
result += "-#{connectionParams.wifiSsid}"
|
||||
|
||||
return "#{result}-#{Date.now()}"
|
36
lib/resin/os/os.spec.coffee
Normal file
36
lib/resin/os/os.spec.coffee
Normal 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()}")
|
Loading…
Reference in New Issue
Block a user