Skip to content

Commit

Permalink
add test case for bootstraplist filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Sep 18, 2024
1 parent 6345bba commit 7c39875
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions tests/unit/conf/Config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict'; // eslint-disable-line

const assert = require('assert');

const joi = require('joi');

const config = require('../../../lib/Config');
const { config, Config } = require('../../../lib/Config');
const { authJoi, inheritedAuthJoi } = require('../../../lib/config/configItems.joi');

describe('backbeat config parsing and validation', () => {

it('should parse correctly the default config', () => {
assert.notStrictEqual(config, undefined);
});
Expand Down Expand Up @@ -64,3 +63,28 @@ describe('backbeat config parsing and validation', () => {
});
});
});

describe('Site name', () => {
let conf;

beforeEach(() => {
conf = new Config();
});

afterEach(() => {
delete process.env.SITE_NAME;
});

it('should filter bootstrapList based on SITE_NAME', () => {
process.env.SITE_NAME = 'test-site-2';
const expectedBootstrapList = conf.bootstrapList.filter(item => item.site === 'test-site-2');
const newConfig = new Config();
assert.deepStrictEqual(newConfig.bootstrapList, expectedBootstrapList);
});

it('should not filter bootstrapList if SITE_NAME is not set', () => {
const expectedBootstrapList = conf.bootstrapList;
const newConfig = new Config();
assert.deepStrictEqual(newConfig.bootstrapList, expectedBootstrapList);
});
});

0 comments on commit 7c39875

Please sign in to comment.