Skip to content

Commit

Permalink
test backbeat config validation
Browse files Browse the repository at this point in the history
Issue: BB-623
  • Loading branch information
Kerkesni committed Nov 6, 2024
1 parent d130b35 commit 8465a7b
Show file tree
Hide file tree
Showing 3 changed files with 398 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ class Config extends EventEmitter {
throw new Error(`could not parse config file: ${err.message}`);
}

this._parseConfig(config);
}

/**
* Parses Backbeat's configuration
* @param {Object} config backbeat configuration
* @returns {undefined}
*/
_parseConfig(config) {
const parsedConfig = joi.attempt(config, backbeatConfigJoi);

if (parsedConfig.extensions) {
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/lib/config/Config.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'; // eslint-disable-line

const assert = require('assert');

const { Config } = require('../../../../lib/Config');
const backbeatConfig = require('./config.json');

describe('Config', () => {
it('should make the probeserver config in the queuePoulator' +
'required when multiple extensions are configured', () => {
const config = new Config();
const testConfig = { ...backbeatConfig };
delete testConfig.queuePopulator.probeServer;
assert.throws(() => config._parseConfig(testConfig));
});

it('should make the probeserver config in the queuePoulator' +
'optional when only notification config is specified', () => {
const config = new Config();
const testConfig = { ...backbeatConfig };
delete testConfig.queuePopulator.probeServer;
testConfig.extensions = { notification: testConfig.extensions.notification };
assert.doesNotThrow(() => config._parseConfig(testConfig));
});
});
Loading

0 comments on commit 8465a7b

Please sign in to comment.