balena-supervisor/test/00-init.ts
Cameron Diver 37feb7e325 Move from dbus-native to dbus
Closes: #1049
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2020-04-13 10:07:14 +01:00

36 lines
880 B
TypeScript

process.env.ROOT_MOUNTPOINT = './test/data';
process.env.BOOT_MOUNTPOINT = '/mnt/boot';
process.env.CONFIG_JSON_PATH = '/config.json';
process.env.DATABASE_PATH = './test/data/database.sqlite';
process.env.DATABASE_PATH_2 = './test/data/database2.sqlite';
process.env.DATABASE_PATH_3 = './test/data/database3.sqlite';
process.env.LED_FILE = './test/data/led_file';
import { stub } from 'sinon';
import * as dbus from 'dbus';
// Stub the dbus objects to dynamically generate the methods
// on request
stub(dbus, 'getBus').returns({
getInterface: (
_obj: unknown,
cb: (err: Error | undefined, iface: dbus.DBusInterface) => void,
) => {
return cb(
undefined,
new Proxy(
{},
{
get(_target, name) {
console.log(`Dbus method ${String(name)} requested`);
return () => {
/* noop */
};
},
},
) as any,
);
},
} as any);