balena-supervisor/test/lib/mocked-dbus.ts
Christina Wang b3b1d47b34
Complete /v1/device/host-config unit tests, modify PATCH route
Change-type: minor
Signed-off-by: Christina Wang <christina@balena.io>
2021-02-18 12:25:44 +09:00

35 lines
817 B
TypeScript

import * as dbus from 'dbus';
import { DBusError, DBusInterface } from 'dbus';
import { stub } from 'sinon';
stub(dbus, 'getBus').returns({
getInterface: (
_serviceName: string,
_objectPath: string,
_interfaceName: string,
interfaceCb: (err: null | DBusError, iface: DBusInterface) => void,
) => {
interfaceCb(null, {
Get: (
_unitName: string,
_property: string,
getCb: (err: null | Error, value: unknown) => void,
) => {
getCb(null, 'this is the value');
},
GetUnit: (
_unitName: string,
getUnitCb: (err: null | Error, unitPath: string) => void,
) => {
getUnitCb(null, 'this is the unit path');
},
StartUnit: (_unitName: string) => {
// noop
},
RestartUnit: (_unitName: string, _mode: string) => {
// noop
},
} as any);
},
} as any);