test: expand onebox integration coverage
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { join } from '@std/path';
|
||||
|
||||
import type { Onebox } from '../../onebox/ts/classes/onebox.ts';
|
||||
|
||||
const disabledDcRouterStatus = {
|
||||
mode: 'disabled' as const,
|
||||
configured: false,
|
||||
running: false,
|
||||
healthy: false,
|
||||
image: '',
|
||||
gatewayUrl: '',
|
||||
opsPort: 0,
|
||||
httpPort: 0,
|
||||
httpsPort: 0,
|
||||
};
|
||||
|
||||
export const disableManagedDcRouterForScenario = (oneboxArg: Onebox) => {
|
||||
const manager = oneboxArg.managedDcRouter as unknown as {
|
||||
getMode: () => 'disabled';
|
||||
prepareGatewaySettings: () => Promise<void>;
|
||||
init: () => Promise<typeof disabledDcRouterStatus>;
|
||||
stop: () => Promise<typeof disabledDcRouterStatus>;
|
||||
getStatus: () => Promise<typeof disabledDcRouterStatus>;
|
||||
};
|
||||
|
||||
manager.getMode = () => 'disabled';
|
||||
manager.prepareGatewaySettings = async () => {};
|
||||
manager.init = async () => disabledDcRouterStatus;
|
||||
manager.stop = async () => disabledDcRouterStatus;
|
||||
manager.getStatus = async () => disabledDcRouterStatus;
|
||||
};
|
||||
|
||||
export const useLocalAppStoreForScenario = (oneboxArg: Onebox, appCatalogDirArg: string) => {
|
||||
const appStore = oneboxArg.appStore as unknown as {
|
||||
catalogCache: unknown;
|
||||
lastFetchTime: number;
|
||||
fetchJson: (pathArg: string) => Promise<unknown>;
|
||||
fetchText: (pathArg: string) => Promise<string>;
|
||||
};
|
||||
|
||||
appStore.catalogCache = null;
|
||||
appStore.lastFetchTime = 0;
|
||||
appStore.fetchText = async (pathArg: string) => {
|
||||
return await Deno.readTextFile(join(appCatalogDirArg, pathArg));
|
||||
};
|
||||
appStore.fetchJson = async (pathArg: string) => {
|
||||
return JSON.parse(await appStore.fetchText(pathArg)) as unknown;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user