diff --git a/src/config/index.ts b/src/config/index.ts index 0ea68ab2..a35db016 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -64,7 +64,7 @@ class Config extends EventEmitter { // NOTE: all 'db' values are stored and loaded as *strings*, apiSecret: { source: 'db', mutable: true }, - name: { source: 'db', mutable: true }, + name: { source: 'db', mutable: true, default: 'local' }, initialConfigReported: { source: 'db', mutable: true, default: 'false' }, initialConfigSaved: { source: 'db', mutable: true, default: 'false' }, containersNormalised: { source: 'db', mutable: true, default: 'false' }, diff --git a/src/device-state.coffee b/src/device-state.coffee index 1b9022ac..0bc5a9ac 100644 --- a/src/device-state.coffee +++ b/src/device-state.coffee @@ -19,8 +19,8 @@ DeviceConfig = require './device-config' ApplicationManager = require './application-manager' validateLocalState = (state) -> - if !state.name? or !validation.isValidShortText(state.name) - throw new Error('Invalid device name') + if state.name? + throw new Error('Invalid device name') if not validation.isValidShortText(state.name) if !state.apps? or !validation.isValidAppsObject(state.apps) throw new Error('Invalid apps') if !state.config? or !validation.isValidEnv(state.config) diff --git a/test/03-config.spec.coffee b/test/03-config.spec.coffee index 8265f0a1..8d3b8a10 100644 --- a/test/03-config.spec.coffee +++ b/test/03-config.spec.coffee @@ -58,8 +58,8 @@ describe 'Config', -> expect(promise).to.eventually.deep.equal({ appUpdatePollInterval: 30000, name: 'a new device name' }) it 'allows removing a db key', -> - promise = @conf.remove('name').then => - @conf.get('name') + promise = @conf.remove('apiSecret').then => + @conf.get('apiSecret') expect(promise).to.be.fulfilled expect(promise).to.eventually.be.undefined