Make the config module a singleton

Change-type: patch
Co-authored-by: Pagan Gazzard <page@balena.io>
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver
2020-06-02 14:29:05 +01:00
parent 10a5fb6aaf
commit ff4a31a0e6
29 changed files with 492 additions and 550 deletions

View File

@ -6,7 +6,7 @@ import { SinonSpy, SinonStub, spy, stub } from 'sinon';
import chai = require('./lib/chai-config');
import prepare = require('./lib/prepare');
import Log from '../src/lib/supervisor-console';
import Config from '../src/config';
import * as config from '../src/config';
import { RPiConfigBackend } from '../src/config/backend';
import DeviceState from '../src/device-state';
import { loadTargetFromFile } from '../src/device-state/preload';
@ -207,7 +207,6 @@ const testTargetInvalid = {
};
describe('deviceState', () => {
const config = new Config();
const logger = {
clearOutOfDateDBLogs() {
/* noop */
@ -231,7 +230,6 @@ describe('deviceState', () => {
});
deviceState = new DeviceState({
config,
eventTracker: eventTracker as any,
logger: logger as any,
apiBinder: null as any,
@ -248,7 +246,6 @@ describe('deviceState', () => {
});
(deviceState as any).deviceConfig.configBackend = new RPiConfigBackend();
await config.init();
});
after(() => {
@ -391,7 +388,7 @@ describe('deviceState', () => {
beforeEach(() => {
// This configStub will be modified in each test case so we can
// create the exact conditions we want to for testing healthchecks
configStub = stub(Config.prototype, 'get');
configStub = stub(config, 'get');
infoLobSpy = spy(Log, 'info');
});