Replace offline -> unmanaged in logs and tests

Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver
2018-12-17 10:52:40 +00:00
parent c533631f70
commit 96b614ad6a
3 changed files with 10 additions and 10 deletions

View File

@ -75,7 +75,7 @@ module.exports = class APIBinder
@config.getMany([ 'unmanaged', 'apiEndpoint', 'currentApiKey' ]) @config.getMany([ 'unmanaged', 'apiEndpoint', 'currentApiKey' ])
.then ({ unmanaged, apiEndpoint, currentApiKey }) => .then ({ unmanaged, apiEndpoint, currentApiKey }) =>
if unmanaged if unmanaged
console.log('Offline Mode is set, skipping API client initialization') console.log('Unmanaged Mode is set, skipping API client initialization')
return return
baseUrl = url.resolve(apiEndpoint, '/v5/') baseUrl = url.resolve(apiEndpoint, '/v5/')
passthrough = _.cloneDeep(requestOpts) passthrough = _.cloneDeep(requestOpts)
@ -105,7 +105,7 @@ module.exports = class APIBinder
@config.getMany([ 'apiEndpoint', 'unmanaged', 'bootstrapRetryDelay' ]) @config.getMany([ 'apiEndpoint', 'unmanaged', 'bootstrapRetryDelay' ])
.then ({ apiEndpoint, unmanaged, bootstrapRetryDelay }) => .then ({ apiEndpoint, unmanaged, bootstrapRetryDelay }) =>
if unmanaged if unmanaged
console.log('Offline Mode is set, skipping API binder initialization') console.log('Unmanaged Mode is set, skipping API binder initialization')
# If we are offline because there is no apiEndpoint, there's a chance # If we are offline because there is no apiEndpoint, there's a chance
# we've went through a deprovision. We need to set the initialConfigReported # we've went through a deprovision. We need to set the initialConfigReported
# value to '', to ensure that when we do re-provision, we'll report # value to '', to ensure that when we do re-provision, we'll report
@ -266,7 +266,7 @@ module.exports = class APIBinder
]) ])
.then (conf) => .then (conf) =>
if conf.unmanaged if conf.unmanaged
throw new Error('Cannot provision dependent device in offline mode') throw new Error('Cannot provision dependent device in unmanaged mode')
if !conf.provisioned if !conf.provisioned
throw new Error('Device must be provisioned to provision a dependent device') throw new Error('Device must be provisioned to provision a dependent device')
# TODO: when API supports it as per https://github.com/resin-io/hq/pull/949 remove userId # TODO: when API supports it as per https://github.com/resin-io/hq/pull/949 remove userId
@ -289,7 +289,7 @@ module.exports = class APIBinder
]) ])
.then (conf) => .then (conf) =>
if conf.unmanaged if conf.unmanaged
throw new Error('Cannot update dependent device in offline mode') throw new Error('Cannot update dependent device in unmanaged mode')
if !conf.provisioned if !conf.provisioned
throw new Error('Device must be provisioned to update a dependent device') throw new Error('Device must be provisioned to update a dependent device')
@balenaApi.patch @balenaApi.patch

View File

@ -23,7 +23,7 @@ describe 'EventTracker', ->
EventTracker.prototype.logEvent.restore() EventTracker.prototype.logEvent.restore()
mixpanel.init.restore() mixpanel.init.restore()
it 'initializes in offline mode', -> it 'initializes in unmanaged mode', ->
promise = @eventTrackerOffline.init({ promise = @eventTrackerOffline.init({
unmanaged: true unmanaged: true
uuid: 'foobar' uuid: 'foobar'
@ -33,11 +33,11 @@ describe 'EventTracker', ->
.then => .then =>
expect(@eventTrackerOffline.client).to.be.null expect(@eventTrackerOffline.client).to.be.null
it 'logs events in offline mode, with the correct properties', -> it 'logs events in unmanaged mode, with the correct properties', ->
@eventTrackerOffline.track('Test event', { appId: 'someValue' }) @eventTrackerOffline.track('Test event', { appId: 'someValue' })
expect(@eventTrackerOffline.logEvent).to.be.calledWith('Event:', 'Test event', JSON.stringify({ appId: 'someValue' })) expect(@eventTrackerOffline.logEvent).to.be.calledWith('Event:', 'Test event', JSON.stringify({ appId: 'someValue' }))
it 'initializes a mixpanel client when not in offline mode', -> it 'initializes a mixpanel client when not in unmanaged mode', ->
promise = @eventTracker.init({ promise = @eventTracker.init({
mixpanelToken: 'someToken' mixpanelToken: 'someToken'
uuid: 'barbaz' uuid: 'barbaz'

View File

@ -135,11 +135,11 @@ describe 'APIBinder', ->
@apiBinder.fetchDevice.restore() @apiBinder.fetchDevice.restore()
balenaAPI.balenaBackend.deviceKeyHandler.restore() balenaAPI.balenaBackend.deviceKeyHandler.restore()
describe 'offline mode', -> describe 'unmanaged mode', ->
before -> before ->
initModels.call(this, '/config-apibinder-offline.json') initModels.call(this, '/config-apibinder-offline.json')
it 'does not generate a key if the device is in offline mode', -> it 'does not generate a key if the device is in unmanaged mode', ->
@config.get('unmanaged').then (mode) => @config.get('unmanaged').then (mode) =>
# Ensure offline mode is set # Ensure offline mode is set
expect(mode).to.equal(true) expect(mode).to.equal(true)
@ -148,7 +148,7 @@ describe 'APIBinder', ->
expect(conf['deviceApiKey']).to.be.empty expect(conf['deviceApiKey']).to.be.empty
expect(conf['uuid']).to.not.be.undefined expect(conf['uuid']).to.not.be.undefined
describe 'Minimal config offline mode', -> describe 'Minimal config unmanaged mode', ->
before -> before ->
initModels.call(this, '/config-apibinder-offline2.json') initModels.call(this, '/config-apibinder-offline2.json')