mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-19 11:16:38 +00:00
Move device logs pubnub event to config
This commit is contained in:
parent
8f13e9bf44
commit
d4b189f785
@ -32,7 +32,7 @@ exports.logs = (uuid) ->
|
||||
# all other actions from exiting on completion
|
||||
pubnub = PubNub.init(resin.config.pubnub)
|
||||
|
||||
channel = "device-#{uuid}-logs"
|
||||
channel = helpers.template(resin.config.events.deviceLogs, { uuid })
|
||||
|
||||
pubnub.history
|
||||
count: LOGS_HISTORY_COUNT
|
||||
|
@ -12,3 +12,6 @@ exports.isDeviceUUIDValid = (uuid, callback) ->
|
||||
return callback?(error) if error?
|
||||
uuidExists = _.findWhere(devices, { uuid })?
|
||||
return callback(null, uuidExists)
|
||||
|
||||
exports.template = (template, data) ->
|
||||
return _.template(template, data)
|
||||
|
@ -63,3 +63,22 @@ describe 'Helpers:', ->
|
||||
expect(error).to.not.exist
|
||||
expect(isValid).to.be.false
|
||||
done()
|
||||
|
||||
describe '#template()', ->
|
||||
|
||||
templateString = 'Hello, <%= name %>'
|
||||
templateData = name: 'John Doe'
|
||||
|
||||
it 'should call _.template', ->
|
||||
templateSpy = sinon.spy(_, 'template')
|
||||
helpers.template(templateString, templateData)
|
||||
|
||||
expect(templateSpy).to.have.been.calledOnce
|
||||
expect(templateSpy).to.have.been.calledWithExactly(templateString, templateData)
|
||||
|
||||
templateSpy.restore()
|
||||
|
||||
it 'should correctly compute the result', ->
|
||||
result = helpers.template(templateString, templateData)
|
||||
expectedResult = _.template(templateString, templateData)
|
||||
expect(result).to.equal(expectedResult)
|
||||
|
@ -18,6 +18,9 @@ config =
|
||||
publish_key: 'pub-c-6cbce8db-bfd1-4fdf-a8c8-53671ae2b226'
|
||||
ssl: true
|
||||
|
||||
events:
|
||||
deviceLogs: 'device-<%= uuid %>-logs'
|
||||
|
||||
config.pluginsDirectory = path.join(config.dataPrefix, 'plugins')
|
||||
|
||||
config.urls =
|
||||
|
Loading…
Reference in New Issue
Block a user